Dedicated routers¶
Classes¶
ForwarderCache¶
Uses uWSGI cache to get target nodes from.
name_separator_strip ¶
Strip leading and trailing name separator from the result.
ForwarderCode¶
Forwards requests to nodes returned by a function.
This allows using user defined functions to calculate. Function must accept key (domain).
Warning
Remember to not put blocking code in your functions. The router is totally non-blocking, do not ruin it!
name_separator_strip ¶
Strip leading and trailing name separator from the result.
ForwarderPath¶
Use the specified base (allows %s pattern) for mapping requests to UNIX sockets.
Examples: * /tmp/sockets/ * /tmp/sockets/%s/uwsgi.sock
name_separator_strip ¶
Strip leading and trailing name separator from the result.
ForwarderSocket¶
name_separator_strip ¶
Strip leading and trailing name separator from the result.
ForwarderSubscriptionServer¶
Forwards requests to nodes returned by the subscription server.
Subscriptions are simple UDP packets that instruct the router which domain maps to which instance or instances.
To subscribe to such a subscription server use .subscriptions.subscribe().
name_separator_strip ¶
Strip leading and trailing name separator from the result.
RouterFast¶
A proxy/load-balancer/router speaking the uwsgi protocol.
You can put it between your webserver and real uWSGI instances to have more control over the routing of HTTP requests to your application servers.
set_basic_params¶
set_connections_params¶
set_owner_params¶
Drop http router privileges to specified user and group.
set_postbuffering_params¶
Sets buffering params.
Web-proxies like nginx are "buffered", so they wait til the whole request (and its body) has been read, and then it sends it to the backends.
set_resubscription_params¶
You can specify a dgram address (udp or unix) on which all the subscriptions request will be forwarded to (obviously changing the node address to the router one).
The system could be useful to build 'federated' setup.
forwarders ¶
Forwarders are kind of registries containing information on where to forward requests.
RouterForkPty¶
Allows allocation of pseudoterminals in jails.
Dealing with containers is now a common deployment pattern. One of the most annoying tasks when dealing with jails/namespaces is 'attaching' to already running instances. The forkpty router aims at simplifyng the process giving a pseudoterminal server to your uWSGI instances. A client connect to the socket exposed by the forkpty router and get a new pseudoterminal connected to a process (generally a shell, but can be whatever you want).
Note
To be used in cooperation with pty plugin.
set_basic_params¶
set_connections_params¶
Sets connection-related parameters.
RouterHttp¶
uWSGI includes an HTTP router/proxy/load-balancer that can forward requests to uWSGI workers.
The server can be used in two ways:
1 2 3 4 | |
Note
If you want to go massive (virtualhosting and zero-conf scaling) combine the HTTP router with the uWSGI Subscription Server.
set_basic_params¶
-
Number of worker processes to spawn.
-
Attach the router to a zerg server.
-
Fallback to the specified node in case of error.
-
Set the maximum number of concurrent events router can manage.
1Default: system dependent. -
Enables cheap mode. When the router is in cheap mode, it will not respond to requests until a node is available. This means that when there are no nodes subscribed, only your local app (if any) will respond. When all the nodes go down, the router will return in cheap mode.
-
Router stats server address to run at.
-
Do not report failed connections to instances.
-
Set internal buffer size in bytes. Default: page size.
-
Allows holding the connection open even if the request has a body.
1 2 3
* <http://uwsgi.readthedocs.io/en/latest/HTTP.html#http-keep-alive> .. note:: See http11 socket type for an alternative. -
Forward subscriptions to the specified subscription server.
set_connections_params¶
-
Set gateway harakiri timeout (seconds).
-
Node socket timeout (seconds). Used to set the SPDY timeout. This is the maximum amount of inactivity after the SPDY connection is closed.
Default: 60.
-
Retry connections to dead static nodes after the specified amount of seconds. Default: 30.
-
Defines the timeout (seconds) while waiting for http headers.
1Default: `socket_timeout`. -
Defines the timeout (seconds) when connecting to backend instances.
1Default: `socket_timeout`.
Sets connection-related parameters.
set_manage_params¶
-
Automatically detect chunked input requests and put the session in raw mode.
-
Automatically transform output to chunked encoding during HTTP 1.1 keepalive (if needed).
-
Automatically gzip content if uWSGI-Encoding header is set to gzip, but content size (Content-Length/Transfer-Encoding) and Content-Encoding are not specified.
-
Automatically detect websockets connections and put the session in raw mode.
-
Automatically put the session in raw mode for
SOURCEHTTP method.1* <http://uwsgi.readthedocs.io/en/latest/Changelog-2.0.5.html#icecast2-protocol-helpers> -
Allow the HTTP router to detect RTSP and chunked requests automatically.
-
Allows the HTTP router to manage PROXY1 protocol requests, such as those made by Haproxy or Amazon Elastic Load Balancer (ELB).
Allows enabling various automatic management mechanics.
set_owner_params¶
forwarders ¶
Forwarders are kind of registries containing information on where to forward requests.
RouterHttps¶
uWSGI includes an HTTPS router/proxy/load-balancer that can forward requests to uWSGI workers.
The server can be used in two ways:
1 2 3 4 | |
Note
If you want to go massive (virtualhosting and zero-conf scaling) combine the HTTP router with the uWSGI Subscription Server.
set_basic_params ¶
-
Number of worker processes to spawn.
-
Attach the router to a zerg server.
-
Fallback to the specified node in case of error.
-
Set the maximum number of concurrent events router can manage.
1Default: system dependent. -
Enables cheap mode. When the router is in cheap mode, it will not respond to requests until a node is available. This means that when there are no nodes subscribed, only your local app (if any) will respond. When all the nodes go down, the router will return in cheap mode.
-
Router stats server address to run at.
-
Do not report failed connections to instances.
-
Set internal buffer size in bytes. Default: page size.
-
Allows holding the connection open even if the request has a body.
1 2 3
* <http://uwsgi.readthedocs.io/en/latest/HTTP.html#http-keep-alive> .. note:: See http11 socket type for an alternative. -
Forward subscriptions to the specified subscription server.
set_connections_params ¶
-
Set gateway harakiri timeout (seconds).
-
Node socket timeout (seconds). Used to set the SPDY timeout. This is the maximum amount of inactivity after the SPDY connection is closed.
Default: 60.
-
Retry connections to dead static nodes after the specified amount of seconds. Default: 30.
-
Defines the timeout (seconds) while waiting for http headers.
1Default: `socket_timeout`. -
Defines the timeout (seconds) when connecting to backend instances.
1Default: `socket_timeout`.
Sets connection-related parameters.
set_manage_params ¶
-
Automatically detect chunked input requests and put the session in raw mode.
-
Automatically transform output to chunked encoding during HTTP 1.1 keepalive (if needed).
-
Automatically gzip content if uWSGI-Encoding header is set to gzip, but content size (Content-Length/Transfer-Encoding) and Content-Encoding are not specified.
-
Automatically detect websockets connections and put the session in raw mode.
-
Automatically put the session in raw mode for
SOURCEHTTP method.1* <http://uwsgi.readthedocs.io/en/latest/Changelog-2.0.5.html#icecast2-protocol-helpers> -
Allow the HTTP router to detect RTSP and chunked requests automatically.
-
Allows the HTTP router to manage PROXY1 protocol requests, such as those made by Haproxy or Amazon Elastic Load Balancer (ELB).
Allows enabling various automatic management mechanics.
set_owner_params ¶
forwarders ¶
Forwarders are kind of registries containing information on where to forward requests.
RouterRaw¶
A pure-TCP load balancer.
Can be used to load balance between the various HTTPS routers.
set_basic_params ¶
-
Number of worker processes to spawn.
-
Attach the router to a zerg server.
-
Fallback to the specified node in case of error.
-
Set the maximum number of concurrent events router can manage.
1Default: system dependent. -
Enables cheap mode. When the router is in cheap mode, it will not respond to requests until a node is available. This means that when there are no nodes subscribed, only your local app (if any) will respond. When all the nodes go down, the router will return in cheap mode.
-
Router stats server address to run at.
-
Do not report failed connections to instances.
-
Set the internal buffer size (default: page size).
set_connections_params¶
forwarders ¶
Forwarders are kind of registries containing information on where to forward requests.
RouterSsl¶
Works in the same way as the RouterRaw, but will terminate ssl connections.
Supports SNI for implementing virtual hosting.
set_basic_params ¶
-
Number of worker processes to spawn.
-
Attach the router to a zerg server.
-
Fallback to the specified node in case of error.
-
Set the maximum number of concurrent events router can manage.
1Default: system dependent. -
Enables cheap mode. When the router is in cheap mode, it will not respond to requests until a node is available. This means that when there are no nodes subscribed, only your local app (if any) will respond. When all the nodes go down, the router will return in cheap mode.
-
Router stats server address to run at.
-
Do not report failed connections to instances.
-
Set the internal buffer size (default: page size).
set_connections_params¶
-
Set gateway harakiri timeout (seconds).
-
Node socket timeout (seconds). Default: 60.
-
Retry connections to dead static nodes after the specified amount of seconds. Default: 30.
-
Maximum number of retries/fallbacks to other nodes. Default: 3.
Sets connection-related parameters.
forwarders ¶
Forwarders are kind of registries containing information on where to forward requests.
RouterTunTap¶
The tuntap router is a non-blocking highly optimized ip router translating from tuntap device to socket streams.
Allows full user-space networking in jails.
It is meant as a replacement for the currently available networking namespaces approaches.
Compared to veth or macvlan it is really simple and allows total control over the routing subsystem
(in addition to a simple customizable firewalling engine).
Generally you spawn the tuntap router in the Emperor instance. Vassals will run in new namespaces in which they create a tuntap device attached to the tuntap router. UNIX sockets are the only way to connect to the tuntap router after jailing.
Vassals should connect to tuntap device.
add_firewall_rule¶
Adds a firewall rule to the router.
The TunTap router includes a very simple firewall for governing vassal's traffic. The first matching rule stops the chain, if no rule applies, the policy is "allow".