uWSGI#

Permite pasar solicitudes a un servidor uWSGI.

Ejemplo de configuración#

location / {
    include    uwsgi_params;
    uwsgi_pass localhost:9000;
}

Directivas#

uwsgi_bind#

Syntax

uwsgi_bind address [transparent] | off;

Predeterminado

Context

http, server, location

Hace que las conexiones salientes a un servidor uWSGI se originen desde la dirección IP local especificada con un puerto opcional. El valor del parámetro puede contener variables. El valor especial off cancela el efecto de la directiva uwsgi_bind heredada del nivel de configuración anterior, lo que permite al sistema asignar automáticamente la dirección IP local y el puerto.

El parámetro transparent permite que las conexiones salientes a un servidor uWSGI se originen desde una dirección IP no local, por ejemplo, desde una dirección IP real de un cliente:

uwsgi_bind $remote_addr transparent;

Para que este parámetro funcione, normalmente es necesario ejecutar los procesos de trabajo de Angie con los privilegios de superusuario. En Linux no es necesario, ya que si se especifica el parámetro transparent, los procesos de trabajo heredan la capacidad CAP_NET_RAW del proceso maestro.

Nota

Es necesario configurar la tabla de enrutamiento del kernel para interceptar el tráfico de red desde el servidor uWSGI.

uwsgi_buffer_size#

Syntax

uwsgi_buffer_size size;

Predeterminado

uwsgi_buffer_size 4k|8k;

Context

http, server, location

Establece el tamaño del búfer utilizado para leer la primera parte de la respuesta recibida del servidor uWSGI. Esta parte generalmente contiene una pequeña cabecera de respuesta. Por defecto, el tamaño del búfer es igual a una página de memoria. Esto es 4K u 8K, dependiendo de la plataforma. Sin embargo, puede hacerse más pequeño.

uwsgi_buffering#

Syntax

uwsgi_buffering on | off;

Predeterminado

uwsgi_buffering on;

Context

http, server, location

Habilita o deshabilita el almacenamiento en búfer de las respuestas del servidor uWSGI.

on

Angie recibe una respuesta del servidor uWSGI lo antes posible, guardándola en los búferes establecidos por las directivas uwsgi_buffer_size y uwsgi_buffers. Si toda la respuesta no cabe en la memoria, una parte de ella puede guardarse en un archivo temporal en el disco. La escritura en archivos temporales está controlada por las directivas uwsgi_max_temp_file_size y uwsgi_temp_file_write_size.

off

La respuesta se pasa al cliente de forma sincrónica, inmediatamente cuando se recibe. Angie no intentará leer toda la respuesta del servidor uWSGI. El tamaño máximo de los datos que Angie puede recibir del servidor a la vez está establecido por la directiva uwsgi_buffer_size.

El almacenamiento en búfer también se puede habilitar o deshabilitar pasando "yes" o "no" en el campo de cabecera de respuesta X-Accel-Buffering. Esta capacidad se puede deshabilitar usando la directiva uwsgi_ignore_headers.

uwsgi_buffers#

Syntax

uwsgi_buffers number size;

Predeterminado

uwsgi_buffers 8 4k | 8k;

Context

http, server, location

Sets the number and size of the buffers used for reading a response from the uWSGI server, for a single connection.

By default, the buffer size is equal to one memory page. This is either 4K or 8K, depending on a platform.

uwsgi_busy_buffers_size#

Syntax

uwsgi_busy_buffers_size size;

Predeterminado

uwsgi_busy_buffers_size 8k | 16k;

Context

http, server, location

Cuando el almacenamiento en búfer de respuestas del servidor uWSGI está habilitado, limita el tamaño total de búferes que pueden estar ocupados enviando una respuesta al cliente mientras la respuesta aún no se ha leído completamente. Mientras tanto, el resto de los búferes se pueden usar para leer la respuesta y, si es necesario, almacenar parte de la respuesta en un archivo temporal.

Por defecto, el tamaño está limitado por el tamaño de dos búferes establecidos por las directivas uwsgi_buffer_size y uwsgi_buffers.

uwsgi_cache#

Syntax

uwsgi_cache zone | off;

Predeterminado

uwsgi_cache off;

Context

http, server, location

Define una zona de memoria compartida utilizada para el almacenamiento en caché. La misma zona puede utilizarse en varios lugares. El valor del parámetro puede contener variables.

off

deshabilita el almacenamiento en caché heredado del nivel de configuración anterior.

uwsgi_cache_background_update#

Syntax

uwsgi_cache_background_update on | off;

Predeterminado

uwsgi_cache_background_update off;

Context

http, server, location

Permite iniciar una subpetición en segundo plano para actualizar un elemento de caché caducado, mientras se devuelve al cliente una respuesta en caché obsoleta.

Advertencia

Tenga en cuenta que es necesario permitir el uso de una respuesta en caché obsoleta cuando se está actualizando.

uwsgi_cache_bypass#

Syntax

uwsgi_cache_bypass ...;

Predeterminado

Context

http, server, location

Define las condiciones bajo las cuales la respuesta no se tomará de una caché. Si al menos un valor de los parámetros de cadena no está vacío y no es igual a "0" entonces la respuesta no se tomará de la caché:

uwsgi_cache_bypass $cookie_nocache $arg_nocache$arg_comment;
uwsgi_cache_bypass $http_pragma    $http_authorization;

Se puede usar junto con la directiva uwsgi_no_cache.

uwsgi_cache_key#

Syntax

uwsgi_cache_key string;

Predeterminado

Context

http, server, location

Define una clave para el almacenamiento en caché, por ejemplo

uwsgi_cache_key localhost:9000$request_uri;

uwsgi_cache_lock#

Syntax

uwsgi_cache_lock on | off;

Predeterminado

uwsgi_cache_lock off;

Context

http, server, location

Cuando está habilitado, solo se permitirá una solicitud a la vez para poblar un nuevo elemento de caché identificado según la directiva uwsgi_cache_key pasando una solicitud a un servidor uWSGI. Otras solicitudes del mismo elemento de caché esperarán a que aparezca una respuesta en la caché o a que se libere el bloqueo de caché para este elemento, hasta el tiempo establecido por la directiva uwsgi_cache_lock_timeout.

uwsgi_cache_lock_age#

Syntax

uwsgi_cache_lock_age time;

Predeterminado

uwsgi_cache_lock_age 5s;

Context

http, server, location

Si la última solicitud pasada al servidor uWSGI para poblar un nuevo elemento de caché no se ha completado durante el tiempo especificado, se puede pasar una solicitud más al servidor uWSGI.

uwsgi_cache_lock_timeout#

Syntax

uwsgi_cache_lock_timeout time;

Predeterminado

uwsgi_cache_lock_timeout 5s;

Context

http, server, location

Establece un tiempo de espera para uwsgi_cache_lock. Cuando el tiempo expira, la solicitud se pasará al servidor uWSGI, sin embargo, la respuesta no se almacenará en caché.

uwsgi_cache_max_range_offset#

Syntax

uwsgi_cache_max_range_offset number;

Predeterminado

Context

http, server, location

Establece un desplazamiento en bytes para las peticiones de rango de bytes. Si el rango está más allá del desplazamiento, la petición de rango se pasará al servidor uWSGI y la respuesta no se almacenará en caché.

uwsgi_cache_methods#

Syntax

uwsgi_cache_methods GET | HEAD | POST ...;

Predeterminado

uwsgi_cache_methods GET HEAD;

Context

http, server, location

Si el método de solicitud del cliente está listado en esta directiva, entonces la respuesta se almacenará en caché. Los métodos "GET" y "HEAD" siempre se añaden a la lista, aunque se recomienda especificarlos explícitamente. Véase también la directiva uwsgi_no_cache.

uwsgi_cache_min_uses#

Syntax

uwsgi_cache_min_uses number;

Predeterminado

uwsgi_cache_min_uses 1;

Context

http, server, location

Establece el número de peticiones después de las cuales la respuesta se almacenará en caché.

uwsgi_cache_path#

Syntax

uwsgi_cache_path path [levels=levels] [use_temp_path=on | off] keys_zone=name:size [inactive=time] [max_size=size] [min_free=size] [manager_files=number] [manager_sleep=time] [manager_threshold=time] [loader_files=number] [loader_sleep=time] [loader_threshold=time];

Predeterminado

Context

http

Establece la ruta y otros parámetros de una caché. Los datos de la caché se almacenan en archivos. El nombre del archivo en una caché es el resultado de aplicar la función MD5 a la clave de caché.

El parámetro levels define los niveles de jerarquía de una caché: de 1 a 3, cada nivel acepta valores 1 o 2. Por ejemplo, en la siguiente configuración:

uwsgi_cache_path /data/angie/cache levels=1:2 keys_zone=one:10m;

los nombres de archivo en una caché se verán así:

/data/angie/cache/c/29/b7f54b2df7773722d382f4809d65029c

Una respuesta almacenada en caché se escribe primero en un archivo temporal, y luego el archivo se renombra. Los archivos temporales y la caché pueden colocarse en diferentes sistemas de archivos. Sin embargo, tenga en cuenta que en este caso un archivo se copia a través de dos sistemas de archivos en lugar de la operación económica de renombrado. Por lo tanto, se recomienda que para cualquier ubicación dada tanto la caché como el directorio que contiene los archivos temporales se coloquen en el mismo sistema de archivos.

El directorio para archivos temporales se establece en función del parámetro use_temp_path.

on

Si este parámetro se omite o se establece en el valor on, se utilizará el directorio establecido por la directiva uwsgi_temp_path para la ubicación dada.

off

Los archivos temporales se colocarán directamente en el directorio de caché.

Además, todas las claves activas y la información sobre los datos se almacenan en una zona de memoria compartida, cuyo nombre y tamaño se configuran mediante el parámetro keys_zone. Una zona de un megabyte puede almacenar alrededor de 8 mil claves.

Los datos almacenados en caché que no se acceden durante el tiempo especificado por el parámetro inactive se eliminan de la caché independientemente de su frescura.

Por defecto, inactive se establece en 10 minutos.

Un proceso especial de administrador de caché monitoriza el tamaño máximo de la caché y la cantidad mínima de espacio libre en el sistema de archivos con caché, y cuando se excede el tamaño o no hay suficiente espacio libre, elimina los datos menos utilizados recientemente. Los datos se eliminan en iteraciones.

max_size

valor umbral máximo para el tamaño de la caché

min_free

valor umbral mínimo para el espacio libre en el sistema de archivos con caché

manager_files

número máximo de elementos de caché eliminados en una iteración

Predeterminado: 100

manager_threshold

limita el tiempo de una iteración

Predeterminado: 200 milisegundos

manager_sleep

tiempo durante el cual se mantiene una pausa entre iteraciones

Predeterminado: 50 milisegundos

Un minuto después de que Angie se inicia, se activa un proceso especial de cargador de caché, que carga en la zona de caché la información sobre los datos previamente almacenados en caché en el sistema de archivos. La carga también ocurre en iteraciones.

loader_files

número máximo de elementos de caché para cargar en una iteración

Predeterminado: 100

loader_threshold

limita el tiempo de una iteración

Predeterminado: 200 milisegundos

loader_sleep

tiempo durante el cual se mantiene una pausa entre iteraciones

Predeterminado: 50 milisegundos

uwsgi_cache_revalidate#

Syntax

uwsgi_cache_revalidate on | off;

Predeterminado

uwsgi_cache_revalidate off;

Context

http, server, location

Habilita la revalidación de elementos de caché expirados utilizando solicitudes condicionales con los campos de cabecera If-Modified-Since y If-None-Match.

uwsgi_cache_use_stale#

Syntax

uwsgi_cache_use_stale error | timeout | invalid_header | updating | http_500 | http_503 | http_403 | http_404 | http_429 | off ...;

Predeterminado

uwsgi_cache_use_stale off;

Context

http, server, location

Determina en qué casos se puede utilizar una respuesta en caché obsoleta. Los parámetros de la directiva coinciden con los parámetros de la directiva uwsgi_next_upstream.

error

Permite usar una respuesta en caché obsoleta si no se puede seleccionar un servidor uwsgi para procesar una solicitud.

updating

Parámetro adicional, permite usar una respuesta en caché obsoleta si actualmente se está actualizando. Esto permite minimizar el número de accesos a servidores uwsgi al actualizar datos en caché.

El uso de una respuesta en caché obsoleta también se puede habilitar directamente en la cabecera de respuesta durante un número específico de segundos después de que la respuesta se volvió obsoleta:

  • La extensión stale-while-revalidate del campo de cabecera Cache-Control permite utilizar una respuesta en caché obsoleta si actualmente se está actualizando.

  • La extensión stale-if-error del campo de cabecera Cache-Control permite utilizar una respuesta en caché obsoleta en caso de error.

Nota

Este método tiene menor prioridad que establecer los parámetros de la directiva.

Para minimizar el número de accesos a los servidores uwsgi al poblar un nuevo elemento de caché, se puede utilizar la directiva uwsgi_cache_lock.

uwsgi_cache_valid#

Syntax

uwsgi_cache_valid [code ...] time;

Predeterminado

Context

http, server, location

Establece el tiempo de almacenamiento en caché para diferentes códigos de respuesta. Por ejemplo, las siguientes directivas

uwsgi_cache_valid 200 302 10m;
uwsgi_cache_valid 404      1m;

estilan 10 minutos de caché para respuestas con códigos 200 y 302 y 1 minuto para respuestas con código 404.

Si solo se especifica el tiempo de caché,

uwsgi_cache_valid 5m;

entonces solo se almacenan en caché las respuestas 200, 301 y 302.

Además, cualquier respuesta puede almacenarse en caché utilizando el parámetro any:

uwsgi_cache_valid 200 302 10m;
uwsgi_cache_valid 301      1h;
uwsgi_cache_valid any      1m;

Nota

Los parámetros de caché también pueden establecerse directamente en la cabecera de respuesta. Este método tiene mayor prioridad que establecer el tiempo de caché usando la directiva.

  • El campo de cabecera X-Accel-Expires establece el tiempo de caché de una respuesta en segundos. El valor 0 deshabilita el almacenamiento en caché para una respuesta. Si el valor comienza con el prefijo @, establece un tiempo absoluto en segundos desde la Época (Epoch), hasta el cual la respuesta puede ser almacenada en caché.

  • Si la cabecera no incluye el campo X-Accel-Expires, los parámetros de caché se determinan por los campos de cabecera Expires o Cache-Control.

  • Una respuesta con el campo de cabecera Set-Cookie no será almacenada en caché.

  • Una respuesta con el campo de cabecera Vary con el valor especial "*" no será almacenada en caché. Una respuesta con el campo de cabecera Vary con otro valor será almacenada en caché teniendo en cuenta los campos de cabecera de solicitud correspondientes.

El procesamiento de uno o más de estos campos de cabecera puede deshabilitarse usando la directiva uwsgi_ignore_headers.

uwsgi_connect_timeout#

Syntax

uwsgi_connect_timeout time;

Predeterminado

uwsgi_connect_timeout 60s;

Context

http, server, location

Define un tiempo de espera para establecer una conexión con un servidor uwsgi. Cabe destacar que este tiempo de espera normalmente no puede exceder los 75 segundos.

uwsgi_connection_drop#

Syntax

uwsgi_connection_drop time | on | off;

Predeterminado

uwsgi_connection_drop off;

Context

http, server, location

Configura la terminación de todas las conexiones al servidor proxy si ha sido eliminado del grupo o marcado como permanentemente no disponible como resultado de un proceso reresolve o comando API DELETE.

Una conexión se termina cuando se procesa el siguiente evento de lectura o escritura para el cliente o el servidor proxy.

Establecer time habilita un tiempo de espera para la terminación de la conexión; con on establecido, las conexiones se cierran inmediatamente.

uwsgi_force_ranges#

Syntax

uwsgi_force_ranges on | off;

Predeterminado

uwsgi_force_ranges off;

Context

http, server, location

Habilita el soporte de rangos de bytes para respuestas almacenadas en caché y no almacenadas en caché desde un servidor uwsgi, independientemente de la presencia del campo Accept-Ranges en estas respuestas.

uwsgi_hide_header#

Syntax

uwsgi_hide_header field;

Predeterminado

Context

http, server, location

Por defecto, Angie no pasa los campos de cabecera Date, Server, X-Pad, y X-Accel-... de la respuesta de un servidor uWSGI al cliente. La directiva uwsgi_hide_header establece campos adicionales que no serán pasados. Si, por el contrario, se necesita permitir el paso de campos, se puede usar la directiva uwsgi_pass_header.

uwsgi_ignore_client_abort#

Syntax

uwsgi_ignore_client_abort on | off;

Predeterminado

uwsgi_ignore_client_abort off;

Context

http, server, location

Determina si la conexión con un servidor uWSGI debe cerrarse cuando un cliente cierra la conexión sin esperar una respuesta.

uwsgi_ignore_headers#

Syntax

uwsgi_ignore_headers field ...;

Predeterminado

Context

http, server, location

Deshabilita el procesamiento de ciertos campos de cabecera de respuesta del servidor uwsgi. Los siguientes campos pueden ser ignorados: X-Accel-Redirect, X-Accel-Expires, X-Accel-Limit-Rate, X-Accel-Buffering, X-Accel-Charset, Expires, Cache-Control, Set-Cookie, y Vary.

Si no se deshabilitan, el procesamiento de estos campos de cabecera tiene el siguiente efecto:

  • X-Accel-Expires, Expires, Cache-Control, Set-Cookie y Vary establecen los parámetros de respuesta caching;

  • X-Accel-Redirect realiza una redirección interna a la URI especificada;

  • X-Accel-Limit-Rate establece el límite de velocidad para la transmisión de una respuesta a un cliente;

  • X-Accel-Buffering habilita o deshabilita buffering de una respuesta;

  • X-Accel-Charset establece el conjunto de caracteres deseado de una respuesta.

uwsgi_intercept_errors#

Syntax

uwsgi_intercept_errors on | off;

Predeterminado

uwsgi_intercept_errors off;

Context

http, server, location

Determina si las respuestas del servidor uwsgi con códigos mayores o iguales a 300 deben pasarse a un cliente o ser interceptadas y redirigidas a Angie para su procesamiento con la directiva error_page.

uwsgi_limit_rate#

Syntax

uwsgi_limit_rate rate;

Predeterminado

uwsgi_limit_rate 0;

Context

http, server, location

Limita la velocidad de lectura de la respuesta desde el servidor uwsgi. La velocidad se especifica en bytes por segundo; se pueden usar variables.

0

desactiva la limitación de velocidad

Nota

El límite se establece por solicitud, por lo que si Angie abre simultáneamente dos conexiones al servidor uwsgi, la velocidad general será el doble del límite especificado. La limitación funciona solo si el almacenamiento en búfer de respuestas del servidor uwsgi está habilitado.

uwsgi_max_temp_file_size#

Syntax

uwsgi_max_temp_file_size size;

Predeterminado

uwsgi_max_temp_file_size 1024m;

Context

http, server, location

Cuando buffering de respuestas del uwsgi está habilitado, y toda la respuesta no cabe en los búferes establecidos por las directivas uwsgi_buffer_size y uwsgi_buffers, una parte de la respuesta puede guardarse en un archivo temporal. Esta directiva establece el tamaño máximo del archivo temporal. El tamaño de los datos escritos en el archivo temporal a la vez se establece mediante la directiva uwsgi_temp_file_write_size.

0

deshabilita el almacenamiento en búfer de respuestas a archivos temporales

Nota

Esta restricción no se aplica a las respuestas que serán almacenadas en caché o guardadas en disco.

uwsgi_modifier1#

Syntax

uwsgi_modifier1 number;

Predeterminado

uwsgi_modifier1 0;

Context

http, server, location

Sets the value of the modifier1 field in the uwsgi packet header.

uwsgi_modifier2#

Syntax

uwsgi_modifier2 number;

Predeterminado

uwsgi_modifier2 0;

Context

http, server, location

Sets the value of the modifier2 field in the uwsgi packet header.

uwsgi_next_upstream#

Syntax

uwsgi_next_upstream error | timeout | invalid_header | http_500 | http_503 | http_403 | http_404 | http_429 | non_idempotent | off ...;

Predeterminado

uwsgi_next_upstream error timeout;

Context

http, server, location

Especifica en qué casos una solicitud debe pasarse al siguiente servidor en el grupo upstream:

error

ocurrió un error de conexión, error de transmisión de solicitud o error de lectura de cabecera de respuesta;

timeout

se produjo un tiempo de espera durante el establecimiento de la conexión, la transmisión de la solicitud o la lectura de la cabecera de respuesta;

invalid_header

el servidor devolvió una respuesta vacía o inválida;

http_500

el servidor devolvió una respuesta con código 500;

http_503

el servidor devolvió una respuesta con código 503;

http_403

el servidor devolvió una respuesta con código 403;

http_404

el servidor devolvió una respuesta con código 404;

http_429

el servidor devolvió una respuesta con código 429;

non_idempotent

normalmente, las solicitudes con métodos no idempotentes (POST, LOCK, PATCH) no se pasan a otro servidor si ya se ha enviado una solicitud a un upstream; habilitar este parámetro permite reintentar dichas solicitudes explícitamente;

off

desactiva el paso de la solicitud al siguiente servidor.

Nota

Debe entenderse que pasar una solicitud al siguiente servidor solo es posible si aún no se ha enviado nada al cliente. Es decir, si ocurre un error o tiempo de espera en medio de la transmisión de una respuesta, no es posible solucionarlo.

La directiva también define qué se considera un intento fallido de comunicación con un servidor.

error

timeout

invalid_header

siempre se consideran intentos fallidos, incluso si no se especifican en la directiva

http_500

http_503

http_429

se consideran intentos fallidos solo si se especifican en la directiva

http_403

http_404

nunca se consideran intentos fallidos

El paso de una solicitud al siguiente servidor puede estar limitado por el número de intentos y por el tiempo.

uwsgi_next_upstream_timeout#

Syntax

uwsgi_next_upstream_timeout time;

Predeterminado

uwsgi_next_upstream_timeout 0;

Context

http, server, location

Limits the time during which a request can be passed to the next server.

0

turns off this limitation

uwsgi_next_upstream_tries#

Syntax

uwsgi_next_upstream_tries number;

Predeterminado

uwsgi_next_upstream_tries 0;

Context

http, server, location

Limits the number of possible tries for passing a request to the next server.

0

turns off this limitation

uwsgi_no_cache#

Syntax

uwsgi_no_cache string ...;

Predeterminado

Context

http, server, location

Defines conditions under which the response will not be saved to a cache. If at least one value of the string parameters is not empty and is not equal to "0" then the response will not be saved:

uwsgi_no_cache $cookie_nocache $arg_nocache$arg_comment;
uwsgi_no_cache $http_pragma    $http_authorization;

Can be used along with the uwsgi_cache_bypass directive.

uwsgi_param#

Syntax

uwsgi_param parameter value [if_not_empty];

Predeterminado

Context

http, server, location

Sets a parameter that should be passed to the uwsgi server. The value can contain text, variables, and their combination. These directives are inherited from the previous configuration level if and only if there are no uwsgi_param directives defined on the current level.

Standard CGI environment variables should be provided as uwsgi headers, see the uwsgi_params file provided in the distribution:

location / {
    include uwsgi_params;
#    ...
}

If the directive is specified with if_not_empty then such a parameter will be passed to the server only if its value is not empty:

uwsgi_param HTTPS $https if_not_empty;

uwsgi_pass#

Syntax

uwsgi_pass [protocol://] address;

Predeterminado

Context

location, if in location

Sets the protocol and address of a uwsgi server. As a protocol, uwsgi or suwsgi (secured uwsgi, uwsgi over SSL) can be specified. The address can be specified as a domain name or IP address, and a port:

uwsgi_pass localhost:9000;
uwsgi_pass uwsgi://localhost:9000;
uwsgi_pass suwsgi://[2001:db8::1]:9090;

or as a UNIX domain socket path:

uwsgi_pass unix:/tmp/uwsgi.socket;

If a domain name resolves to several addresses, all of them will be used in a round-robin fashion. In addition, an address can be specified as a server group.

Parameter value can contain variables. In this case, if an address is specified as a domain name, the name is searched among the described server groups, and, if not found, is determined using a resolver.

uwsgi_pass_header#

Syntax

uwsgi_pass_header field ...;

Predeterminado

Context

http, server, location

Permits passing otherwise disabled header fields from a uwsgi server to a client.

uwsgi_pass_request_body#

Syntax

uwsgi_pass_request_body on | off;

Predeterminado

uwsgi_pass_request_body on;

Context

http, server, location

Indicates whether the original request body is passed to the uwsgi server. See also the uwsgi_pass_request_headers directive.

uwsgi_pass_request_headers#

Syntax

uwsgi_pass_request_headers on | off;

Predeterminado

uwsgi_pass_request_headers on;

Context

http, server, location

Enables or disables passing of header fields from the original request to the uwsgi server. See also the uwsgi_pass_request_body directive.

uwsgi_read_timeout#

Syntax

uwsgi_read_timeout time;

Predeterminado

uwsgi_read_timeout 60s;

Context

http, server, location

Defines a timeout for reading a response from the uwsgi server. The timeout is set only between two successive read operations, not for the transmission of the whole response. If the uwsgi server does not transmit anything within this time, the connection is closed.

uwsgi_request_buffering#

Syntax

uwsgi_request_buffering on | off;

Predeterminado

uwsgi_request_buffering on;

Context

http, server, location

Enables o deshabilita el almacenamiento en búfer del cuerpo de la solicitud del cliente.

on

El cuerpo de la solicitud se lee completamente del cliente antes de enviar la solicitud al servidor uwsgi.

off

El cuerpo de la solicitud se envía al servidor uwsgi inmediatamente a medida que se recibe. En este caso, la solicitud no se puede pasar al siguiente servidor si Angie ya ha comenzado a enviar el cuerpo de la solicitud.

Cuando se utiliza la codificación de transferencia fragmentada HTTP/1.1 para enviar el cuerpo de la solicitud original, el cuerpo de la solicitud se almacenará en búfer independientemente del valor de la directiva.

uwsgi_send_timeout#

Syntax

uwsgi_send_timeout time;

Predeterminado

uwsgi_send_timeout 60s;

Context

http, server, location

Sets a timeout for transmitting a request to the uwsgi server. The timeout is set only between two successive write operations, not for the transmission of the whole request. If the uwsgi server does not receive anything within this time, the connection is closed.

uwsgi_socket_keepalive#

Syntax

uwsgi_socket_keepalive on | off;

Predeterminado

uwsgi_socket_keepalive off;

Context

http, server, location

Configures the "TCP keepalive" behavior for outgoing connections to a uwsgi server.

off

By default, the operating system's settings are in effect for the socket.

on

The SO_KEEPALIVE socket option is turned on for the socket.

uwsgi_ssl_certificate#

Syntax

uwsgi_ssl_certificate file;

Predeterminado

Context

http, server, location

Specifies a file with the certificate in the PEM format used for authentication to a secured uwsgi server. Variables can be used in the file name.

uwsgi_ssl_certificate_cache#

Syntax

uwsgi_ssl_certificate_cache off;

uwsgi_ssl_certificate_cache max=N [inactive=time] [valid=time];

Predeterminado

uwsgi_ssl_certificate_cache off;

Context

http, server, location

Defines a cache that stores SSL certificates y secret keys specified using variables.

El/directive admite los siguientes parámetros:

  • max — establece el número máximo de elementos en la caché. Cuando la caché desborda, se eliminan los elementos menos utilizados (LRU).

  • inactive — define el tiempo después del cual un elemento se elimina si no ha sido accedido. Predeterminado: 10 segundos.

  • valid — define el tiempo durante el cual un elemento en caché se considera válido y puede reutilizarse. Predeterminado: 60 segundos. Después de este periodo, los certificados se recargan o revalida.

  • off — desactiva la caché.

Ejemplo:

uwsgi_ssl_certificate       $uwsgi_ssl_server_name.crt;
uwsgi_ssl_certificate_key   $uwsgi_ssl_server_name.key;
uwsgi_ssl_certificate_cache max=1000 inactive=20s valid=1m;

uwsgi_ssl_certificate_key#

Syntax

uwsgi_ssl_certificate_key file;

Predeterminado

Context

http, server, location

Specifies a file with the secret key in the PEM format used for authentication to a secured uwsgi server.

The value engine:`name`:id can be specified instead of the file, which loads a secret key with a specified id from the OpenSSL engine name.

Variables can be used in the file name.

uwsgi_ssl_ciphers#

Syntax

uwsgi_ssl_ciphers ciphers;

Predeterminado

uwsgi_ssl_ciphers DEFAULT;

Context

http, server, location

Specifies the enabled ciphers for requests to a secured uwsgi server. The ciphers are specified in the format understood by the OpenSSL library.

The list of ciphers depends on the version of OpenSSL installed. The full list can be viewed using the openssl ciphers command.

Advertencia

The uwsgi_ssl_ciphers directive does not configure ciphers for TLS 1.3 when using OpenSSL. To tune TLS 1.3 ciphers with OpenSSL, use the uwsgi_ssl_conf_command directive, which was added to support advanced SSL configuration.

  • In LibreSSL, TLS 1.3 ciphers can be configured using uwsgi_ssl_ciphers.

  • In BoringSSL, TLS 1.3 ciphers cannot be configured at all.

uwsgi_ssl_conf_command#

Syntax

uwsgi_ssl_conf_command name value;

Predeterminado

Context

http, server, location

Sets arbitrary OpenSSL configuration commands when establishing a connection with a secured uwsgi server.

Nota

The directive is supported when using OpenSSL 1.0.2 or higher. To configure TLS 1.3 ciphers in OpenSSL, use the ciphersuites command.

Multiple uwsgi_ssl_conf_command directives can be specified on the same level. These directives are inherited from the previous configuration level if and only if there are no uwsgi_ssl_conf_command directives defined on the current level.

Advertencia

Note that reconfiguring OpenSSL directly might result in unexpected behavior.

uwsgi_ssl_crl#

Syntax

uwsgi_ssl_crl file;

Predeterminado

Context

http, server, location

Specifies a file with revoked certificates (CRL) in the PEM format used to verify the certificate of the secured uwsgi server.

uwsgi_ssl_name#

Syntax

uwsgi_ssl_name name;

Predeterminado

uwsgi_ssl_name `host name from uwsgi_pass;`

Context

http, server, location

Allows overriding the server name used to verify the certificate of the secured uwsgi server and to be passed through SNI when establishing a connection with the secured uwsgi server.

By default, the host name from the uwsgi_pass directive is used.

uwsgi_ssl_password_file#

Syntax

uwsgi_ssl_password_file file;

Predeterminado

Context

http, server, location

Specifies a file with passphrases for secret keys where each passphrase is specified on a separate line. Passphrases are tried in turn when loading the key.

uwsgi_ssl_protocols#

Syntax

uwsgi_ssl_protocols [SSLv2] [SSLv3] [TLSv1] [TLSv1.1] [TLSv1.2] [TLSv1.3];

Predeterminado

uwsgi_ssl_protocols TLSv1.2 TLSv1.3;

Context

http, server, location

Distinto en la versión 1.2.0: TLSv1.3 parameter added to default set.

Enables the specified protocols for requests to a secured uwsgi server.

uwsgi_ssl_server_name#

Syntax

uwsgi_ssl_server_name on | off;

Predeterminado

uwsgi_ssl_server_name off;

Context

http, server, location

Habilita o deshabilita el paso del nombre del servidor establecido por la directiva uwsgi_ssl_name a través de la extensión TLS Server Name Indication (SNI, RFC 6066) al establecer una conexión con el servidor uwsgi seguro.

uwsgi_ssl_session_reuse#

Syntax

uwsgi_ssl_session_reuse on | off;

Predeterminado

uwsgi_ssl_session_reuse on;

Context

http, server, location

Determina si las sesiones SSL pueden reutilizarse cuando se trabaja con el servidor uwsgi seguro. Si aparecen errores "SSL3_GET_FINISHED:digest check failed" en los registros, intente deshabilitar la reutilización de sesiones.

uwsgi_ssl_trusted_certificate#

Syntax

uwsgi_ssl_trusted_certificate file;

Predeterminado

Context

http, server, location

Specifies a file with trusted CA certificates in the PEM format used to verify the certificate of the secured uwsgi server.

uwsgi_ssl_verify#

Syntax

uwsgi_ssl_verify on | off;

Predeterminado

uwsgi_ssl_verify off;

Context

http, server, location

Enables or disables verification of the secured uwsgi server certificate.

uwsgi_ssl_verify_depth#

Syntax

uwsgi_ssl_verify_depth number;

Predeterminado

uwsgi_ssl_verify_depth 1;

Context

http, server, location

Sets the verification depth in the secured uwsgi server certificates chain.

uwsgi_store#

Syntax

uwsgi_store on | off | string;

Predeterminado

uwsgi_store off;

Context

http, server, location

Enables saving of files to a disk.

on

saves files with paths corresponding to the directives alias o root

off

disables saving of files

The file name can be set explicitly using string with variables:

uwsgi_store /data/www$original_uri;

La hora de modificación de los archivos se establece según el campo de cabecera de respuesta Last-Modified recibido. La respuesta se escribe primero en un archivo temporal, y luego el archivo se renombra. Los archivos temporales y el almacenamiento persistente pueden colocarse en diferentes sistemas de archivos. Sin embargo, tenga en cuenta que en este caso un archivo se copia a través de dos sistemas de archivos en lugar de la operación económica de renombrado. Por lo tanto, se recomienda que para cualquier ubicación dada, tanto los archivos guardados como el directorio que contiene archivos temporales, establecido por la directiva uwsgi_temp_path, se coloquen en el mismo sistema de archivos.

Esta directiva puede usarse para crear copias locales de archivos estáticos inmutables, por ejemplo:

location /images/ {
    root               /data/www;
    error_page         404 = /fetch$uri;
}

location /fetch/ {
    internal;

    uwsgi_pass         backend:9000;
    ...

    uwsgi_store        on;
    uwsgi_store_access user:rw group:rw all:r;
    uwsgi_temp_path    /data/temp;

    alias              /data/www/;
}

uwsgi_store_access#

Syntax

uwsgi_store_access users:permissions ...;

Predeterminado

uwsgi_store_access user:rw;

Context

http, server, location

Establece permisos de acceso para archivos y directorios recién creados, por ejemplo:

uwsgi_store_access user:rw group:rw all:r;

Si se especifican permisos de acceso para group o all, los permisos de usuario pueden omitirse:

uwsgi_store_access group:rw all:r;

uwsgi_temp_file_write_size#

Syntax

uwsgi_temp_file_write_size size;

Predeterminado

uwsgi_temp_file_write_size 8k|16k;

Context

http, server, location

Limita el tamaño de datos escritos a un archivo temporal a la vez, cuando el almacenamiento en búfer de respuestas del uwsgi está habilitado. Por defecto, el tamaño está limitado por dos búferes establecidos por las directivas uwsgi_buffer_size y uwsgi_buffers. El tamaño máximo de un archivo temporal se establece mediante la directiva uwsgi_max_temp_file_size.

uwsgi_temp_path#

Syntax

uwsgi_temp_path path [level1 [level2 [level3]]]';

Predeterminado

uwsgi_temp_path uwsgi_temp; (la ruta depende del parámetro de compilación build parameter --http-uwsgi-temp-path)

Context

http, server, location

Define un directorio para almacenar archivos temporales con datos recibidos de servidores uwsgi. Se puede utilizar una jerarquía de subdirectorios de hasta tres niveles debajo del directorio especificado. Por ejemplo, en la siguiente configuración

uwsgi_temp_path /spool/angie/uwsgi_temp 1 2;

un archivo temporal podría verse así:

/spool/angie/uwsgi_temp/7/45/00000123457

Véase también el parámetro use_temp_path de la directiva uwsgi_cache_path.