current position:Home>What we learned today - nginx reverse proxy

What we learned today - nginx reverse proxy

2021-08-24 23:26:38 Ten days to the South

Nginx Reverse proxy

One , Concept

1. Reverse proxy :

Used in Corporate Cluster Architecture , client ——》 agent 《——》 Server side .

2. function :

Routing functions :image.png
Load balancing :
Dynamic and static separation :
Data caching :

3. The difference between forward agent and reverse agent

The object of forward proxy is the client , Serving clients ;
The object of reverse proxy is the server side , Serve the server .

4. Supported proxy protocols


Two , Relevant configuration parameters of the agent


proxy_set_header Host $http_host;
When the agent requests from the back end, it carries Host Variable , No loss of header information ;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Clients access back-end services through proxy services , The back-end service will record the real client address through this variable ;


proxy_http_version 1.0 | 1.1;
Used by the proxy when requesting from the backend HTTP Protocol version , Default 1.0 edition ;
3.proxy_connect_timeout xs;
nginx Proxy and back-end server “ Connection timeout ” Time ( Agent connection timeout ),x second ;
proxy_read_timeout xs;
nginx The agent waits for the back-end server “ Respond to (Header) Overtime ” Time ,x second ;
proxy_send_timeout xs;
Back end servers “ data (Data) Send it back to nginx Agent timeout ” Time ,x second ;
4.proxy_buffer( buffer )
proxy_buffering on | off;
If the response message is too large to be stored in memory , Some of them will be saved to a temporary file on disk ;
proxy_buffer_size 64k;
Buffer size ;

3、 ... and , Parameter sorting

vim /etc/nginx/proxy_params

proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 30;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_buffering on;
proxy_buffer_size 64k;
proxy_buffers 4 64k;
Put into a file , Then in the configuration file include that will do .

copyright notice
author[Ten days to the South],Please bring the original link to reprint, thank you.

Random recommended