Proxy#
Allows proxying data streams over TCP, UDP, and UNIX domain sockets. Makes outgoing connections to a proxied server originate from the specified local IP address. Parameter value can contain variables. The special value By default, this value is evaluated once when the session is initialized, before
a proxied server is selected. In Angie PRO, evaluation happens after each
proxied server selection (including retries), so the bind address can depend on
the selected server; for example, via the The For this parameter to work,
Angie worker processes usually need to run
with superuser privileges.
On Linux, this is not required:
if the Note The kernel routing table should also be configured
to intercept network traffic from the proxied server. Sets the size of the buffer used for reading data from the proxied server. Also sets the size of the buffer used for reading data from the client. Defines a timeout for establishing a connection with a proxied server. Enables termination of all sessions to the proxied server after it has been
removed from the group or marked as permanently unavailable by a reresolve process or the API command
A session is terminated when the next read or write event is processed for
either the client or the proxied server. Setting time enables a session termination timeout;
with Limits the speed of reading the data from the proxied server. The disables rate limiting Note The limit is set per a connection, so if Angie simultaneously opens two connections to the proxied server, the overall rate will be twice as much as the specified limit. Parameter value can contain variables. It may be useful in cases where rate should be limited depending on a certain condition: Enables or disables closing each direction of a TCP connection independently ("TCP half-close"). If enabled, proxying over TCP will be kept until both sides close the connection. When a connection to the proxied server cannot be established, determines whether a client connection will be passed to the next server in the upstream pool. Passing a connection to the next server can be limited by the number of tries and by time. Limits the time allowed to pass a connection to the next server. turns off this limitation Limits the number of possible tries for passing a connection to the next server. turns off this limitation Sets the address of a proxied server. The or as a UNIX domain socket path: 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. If the referenced group is portless (PRO), meaning its
servers are defined without a port, the port is appended to the group name: The port suffix is required for a portless group and is not allowed for a group
whose servers already define ports; violating either rule is a configuration
error. The address can also be specified using variables
(along with the port suffix, if allowed): In this case, the server name is searched among the described server groups and, if not found, is determined using a resolver. Enables the PROXY protocol for connections to a proxied server. Added in version 1.11.0. Adds a TLV to the PROXY protocol v2 header sent to a proxied server. The value can contain variables. The name can be a TLV type name or its numeric value; in the latter case, the value is specified in hexadecimal and must start with 0x. For SSL TLVs, use the Sets the PROXY protocol version used for connections to a proxied server. The setting is effective when proxy_protocol is enabled. Version 2 allows sending TLVs configured by the proxy_protocol_tlv directive. Sets the number of client datagrams at which binding between a client and existing UDP stream session is dropped. After receiving the specified number of datagrams, next datagram from the same client starts a new session. The session terminates when all client datagrams are transmitted to a proxied server and the expected number of responses is received, or when it reaches a timeout. Sets the number of datagrams expected from the proxied server in response to a client datagram if the UDP protocol is used. The number serves as a hint for session termination. By default, the number of datagrams is not limited. If zero value is specified, no response is expected. However, if a response is received and the session is still not finished, the response will be handled. Configures the "TCP keepalive" behavior for outgoing connections to a proxied server. By default, the operating system's settings are in effect for the socket. The SO_KEEPALIVE socket option is turned on for the socket. Enables the SSL/TLS protocol for connections to a proxied server. Specifies the list of protocols to advertise via the
ALPN
extension when establishing a connection with the proxied server, for example: The parameter value can contain variables. Specifies a file with the certificate in the PEM format used for authentication to a proxied server. The file name can contain variables. When proxy_ssl_ntls is enabled, the directive takes two arguments instead of one: Default stream, server Defines a cache that stores SSL certificates and secret keys specified using variables. The directive supports the following parameters: Example: Specifies a file with the secret key in the PEM format used for authentication to a proxied server. The value The value The file name can contain variables. When proxy_ssl_ntls is enabled, the directive accepts two arguments instead of one: Specifies the enabled ciphers for requests to a proxied 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 Warning The In LibreSSL, TLS 1.3 ciphers can be configured using
In BoringSSL, TLS 1.3 ciphers cannot be configured. Sets arbitrary OpenSSL configuration commands when establishing a connection with the proxied server. Note The directive is supported when using OpenSSL 1.0.2 or higher.
To configure TLS 1.3 ciphers with OpenSSL, use the Several proxy_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 proxy_ssl_conf_command directives defined on the current level. Warning Note that configuring OpenSSL directly might result in unexpected behavior. Specifies a file with revoked certificates (CRL) in the PEM format used to verify the certificate of the proxied server. Specifies a file to log SSL/TLS keys for connections to proxied servers in the context,
using the SSLKEYLOGFILE
format used by tools such as Wireshark to decrypt captured TLS traffic. The directive should not be used with LibreSSL. Warning The file contains sensitive TLS key material that can decrypt captured
traffic for the corresponding connections. Use this directive only for
debugging or protocol analysis, restrict access to the file, and remove it
when no longer needed. Allows overriding the server name used to verify the certificate of the proxied server and to be passed through SNI when establishing a connection with the proxied server. The server name can also be specified using variables. By default, the host name from the address specified by the proxy_pass directive is used. Enables client-side support for NTLS when using the TongSuo TLS library. Note Angie must be built using the 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. Default stream, server Enables the specified protocols for requests to a proxied server. Enables or disables passing the server name
specified by the proxy_ssl_name directive
through the
Server Name Indication
TLS extension
(SNI,
RFC 6066)
when establishing a connection with the proxied server. Determines whether SSL sessions can be reused when working with the proxied server. If the errors "SSL3_GET_FINISHED:digest check failed" appear in the logs, try disabling session reuse. Specifies a file with trusted CA certificates in the PEM format used to verify the certificate of the proxied server. Enables or disables verification of the proxied server certificate. Sets the verification depth in the proxied server certificates chain. Sets a timeout between two successive read or write operations on client or proxied server connections. If no data is transmitted within this time, the connection is closed. Limits the speed of reading the data from the client. The rate is specified in bytes per second. disables rate limiting Note The limit is set per connection, so if the client simultaneously opens two connections, the overall rate will be twice as much as the specified limit. The parameter value can contain variables. This may be useful in cases where the rate should be limited depending on a certain condition:Configuration Example#
server {
listen 127.0.0.1:12345;
proxy_pass 127.0.0.1:8080;
}
server {
listen 12345;
proxy_connect_timeout 1s;
proxy_timeout 1m;
proxy_pass example.com:12345;
}
server {
listen 53 udp reuseport;
proxy_timeout 20s;
proxy_pass dns.example.com:53;
}
server {
listen [::1]:12345;
proxy_pass unix:/tmp/stream.socket;
}
Directives#
proxy_bind#
off cancels the effect of the proxy_bind directive inherited from the previous configuration level, which allows the system to auto-assign the local IP address.$upstream_current_addr
variable. If the evaluated value is empty, no binding is made.transparent parameter allows outgoing connections to a proxied
server originate from a non-local IP address, for example, from a real IP
address of a client:proxy_bind $remote_addr transparent;
transparent parameter is specified,
worker processes inherit the CAP_NET_RAW capability from the master process.proxy_buffer_size#
proxy_connect_timeout#
proxy_connection_drop#
DELETE.on set, sessions are dropped immediately.proxy_download_rate#
rate is specified in bytes per second.0map $slow $rate {
1 4k;
2 8k;
}
proxy_download_rate $rate;
proxy_half_close#
proxy_next_upstream#
proxy_next_upstream_timeout#
0proxy_next_upstream_tries#
0proxy_pass#
address can be specified as a domain name or IP address, and a port:proxy_pass localhost:12345;
proxy_pass unix:/tmp/stream.socket;
proxy_pass backend:8443;
proxy_pass $upstream;
proxy_protocol#
proxy_protocol_tlv#
ssl_ prefix; the special ssl_verify name sets the verify field of the SSL TLV. The directive is used only with proxy_protocol_version set to 2.proxy_protocol_version#
proxy_requests#
proxy_responses#
proxy_socket_keepalive#
offonproxy_ssl#
proxy_ssl_alpn#
proxy_ssl_alpn h2 http/1.1;
proxy_ssl_certificate#
server {
proxy_ssl_ntls on;
proxy_ssl_certificate sign.crt enc.crt;
proxy_ssl_certificate_key sign.key enc.key;
proxy_ssl_ciphers "ECC-SM2-WITH-SM4-SM3:ECDHE-SM2-WITH-SM4-SM3:RSA";
proxy_pass backend:12345;
}
proxy_ssl_certificate_cache#
proxy_ssl_certificate_cache off;proxy_ssl_certificate_cache max=N [inactive=time] [valid=time];proxy_ssl_certificate_cache off;max — sets the maximum number of elements in the cache. When the cache
overflows, the least recently used (LRU) elements are removed.inactive — defines the time after which an element is removed if it
has not been accessed during this time, even if still within its
valid period; each access resets this timer. The default is 10
seconds.valid — defines the time during which a cached element is considered
valid and can be reused. The default is 60 seconds. After this period,
certificates are reloaded or revalidated.off — disables the cache.proxy_ssl_certificate $proxy_ssl_server_name.crt;
proxy_ssl_certificate_key $proxy_ssl_server_name.key;
proxy_ssl_certificate_cache max=1000 inactive=20s valid=1m;
proxy_ssl_certificate_key#
engine:`name`:id can be specified instead of the file, which loads a secret key with a specified id from the OpenSSL engine name.store:scheme:id can be specified instead of the file, which is used to load a secret key with a specified id and OpenSSL provider registered URI scheme, such as pkcs11.server {
proxy_ssl_ntls on;
proxy_ssl_certificate sign.crt enc.crt;
proxy_ssl_certificate_key sign.key enc.key;
proxy_ssl_ciphers "ECC-SM2-WITH-SM4-SM3:ECDHE-SM2-WITH-SM4-SM3:RSA";
proxy_pass backend:12345;
}
proxy_ssl_ciphers#
openssl ciphers command.proxy_ssl_ciphers directive does not configure ciphers for TLS 1.3 when
using OpenSSL. To configure TLS 1.3 ciphers with OpenSSL, use the
proxy_ssl_conf_command directive, which was added for advanced
SSL configuration.proxy_ssl_ciphers.proxy_ssl_conf_command#
ciphersuites command.proxy_ssl_crl#
proxy_ssl_keylog_file#
proxy_ssl_name#
proxy_ssl_ntls#
server {
proxy_ssl_ntls on;
proxy_ssl_certificate sign.crt enc.crt;
proxy_ssl_certificate_key sign.key enc.key;
proxy_ssl_ciphers "ECC-SM2-WITH-SM4-SM3:ECDHE-SM2-WITH-SM4-SM3:RSA";
proxy_pass backend:12345;
}
--with-ntls configuration parameter, with the corresponding SSL library with NTLS support./configure --with-openssl=../Tongsuo-8.3.0 \
--with-openssl-opt=enable-ntls \
--with-ntls
proxy_ssl_password_file#
proxy_ssl_protocols#
proxy_ssl_protocols [SSLv2] [SSLv3] [TLSv1] [TLSv1.1] [TLSv1.2] [TLSv1.3];proxy_ssl_protocols TLSv1.2 TLSv1.3;proxy_ssl_server_name#
proxy_ssl_session_reuse#
proxy_ssl_trusted_certificate#
proxy_ssl_verify#
proxy_ssl_verify_depth#
proxy_timeout#
proxy_upload_rate#
0map $slow $rate {
1 4k;
2 8k;
}
proxy_upload_rate $rate;