Memcached_passSend a request to the memcached ServerNote that in these cases, the rules for specifying addresses may be different. You may also need to pass additional parameters to the server (see the reference documentation for more detail ).
Note that the rules for IP Address Allocation on various servers may be different in these cases. You may also need to send additional parameters to the server (to the relevant documentation for more details ).
TheProxy_passDirective can also point to a named group of servers. In this case, requests are distributed among the servers in the group according to the specified method.
The proxy_pass command can also point to a named host group. In this case, requests are distributed to hosts in the group using the specified method.
Passing Request Headers
Send request headerBy default, NGINX redefines two header fields in proxied requests, "Host" and "Connection", and eliminates the header fields whose values are empty strings. "Host" is set to the $ proxy_host variable, and "Connection" is set to close.
By default, Nginx redefines the two header fields requested by the proxy, "Host" and "Connection", and removes the header fields with null values ." Host is set to $ proxy_host variable, and Connection is set to disabled.
To change these setting, as well as modify other header fields, useProxy_set_header Directive. This directive can be specified in a location or higher. It can also be specified in a particle server context or in the http block. For example:
To change these settings and modify other header fields, useProxy_set_headerCommand. This command can be used in location or higher level. It can also be specified in a special server block or http block. For example:
location /some/path/ { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://localhost:8000;}
In this configuration the "Host" field is set to the $ host variable.In this configuration, set the "Host" field to the $ host variable.
To prevent a header field from being passed to the proxied server, set it to an empty string as follows:
To prevent a header field from being sent to the proxy server, set it as an empty string as follows:
location /some/path/ { proxy_set_header Accept-Encoding ""; proxy_pass http://localhost:8000;}
Caching ing Buffers
Configure the bufferBy default NGINX buffers responses from proxied servers. A response is stored in the internal buffers and is not sent to the client until the whole response is already ed. buffering helps to optimize performance with slow clients, which can waste proxied server time if the response is passed from NGINX to the client synchronously. however, when buffering is enabled NGINX allows the proxied server to process responses quickly, while NGINX stores the responses for as much time as the clients need to download them.
Nginx caches responses from the proxy server by default. A response is stored in the kernel buffer until the entire response is received and sent to the client. The buffer can help optimize performance by slowing down the client. If the response is synchronously sent from Nginx to the client, it will waste time on the proxy server. However, when the buffer enables Nginx, the proxy server can quickly process the response, and Nginx will store the response until the client download is complete.
The directive that is responsible for enabling and disabling buffering is proxy_buffering. By default it is set to on and buffering is enabled.
The proxy_buffering command is used to enable and Disable buffering. The default value is on, and the buffer is enabled.
TheProxy_buffersDirective controls the size and the number of buffers allocated for a request. The first part of the response from a proxied server is stored in a separate buffer, the size of which is set withProxy_buffer_sizeDirective. This part usually contains a comparatively small response header and can be made smaller than the buffers for the rest of the response.
Proxy_buffersThe command controls the size and quantity of the buffer allocated to the request. The first part of the response returned from the proxy server is stored in a separate buffer zone.Proxy_buffer_sizeCommand settings. This part usually contains a relatively small response header, making the rest of the response smaller than the buffer.
In the following example, the default number of buffers is increased and the size of the buffer for the first portion of the response is made smaller than the default.
In the following example. Increase the number of default buffers and reduce the size of the buffer that saves the first part of the response.
location /some/path/ { proxy_buffers 16 4k; proxy_buffer_size 2k; proxy_pass http://localhost:8000;}
If buffering is disabled, the response is sent to the client synchronously while it is refreshing it from the proxied server. this behavior may be desirable for fast interactive clients that need to start loading the response as soon as possible.
If the buffer zone is disabled, the response is synchronously sent to the client as soon as it is received by the proxy server. This behavior may satisfy the fast interaction client that needs to receive responses as quickly as possible.
To disable buffering in a specific location, placeProxy_bufferingDirective in the location with the off parameter, as follows:
To disable the buffer of a location, add the proxy_buffering command to the location and set its value to off, as shown below:
location /some/path/ { proxy_buffering off; proxy_pass http://localhost:8000;}
In this case NGINX uses only the buffer configuredProxy_buffer_sizeTo store the current part of a response.
In this way, Nginx only uses the buffer configured through proxy_buffer_size to save the current part of the response.