Nginx Reverse Proxy

Quote: https://baijiahao.baidu.com/s?id=1600687025749463237&wfr=spider&for=pc

Refer to the diagram, forward proxy use: Client Server can not access directly, such as Google FQ, so the request is sent to the agent, the agent can access the Server and returns information back to the Client.

Reverse proxy use: a Domain Name Server IP hides are not directly exposed, Proxy to act as a springboard for machine / front-end functions; 2 for a large number of concurrent client requests, be distributed to the various servers, load balancing.

Reverse proxy TCP / UDP load balancing configuration and options: edit nginx.conf file

# Number of processes, a process usually enough
worker_processes  1;  
 
events {  
    # Single process maximum number of connections (maximum number of connections = connections * number of processes)
    worker_connections  1024;  
}  

#Tcp / the UDP socket fixed string: stream
stream {
    # Reverse proxy URL management
    upstream myproxy {
        # Hashing the source address is an IP access client hash results after allocation, so that each client request with a fixed back-end server.
        #ip_hash;    
        
        # According to the length of time the server response to be distributed, the shorter the server response time, priority distribution.
        #fair 

     # normal distribution server
192.168.3.22:13333; server 192.168.3.22:13334; # Weight, the greater the weight the right, the more the number of connections, the greater the pressure. #server 11.22.333.44:5555 weight=2; #server 11.22.333.11:6666 weight=1; # Indicates that the current temporary server does not participate in load. #server 11.22.333.22:8888 down; # All other non-backup machine down or busy, request backup machine. So this machine will be the lightest pressure. #server 11.22.333.33:8888 backup; } server { #region uniform listening port the listen 13335 ; # Connection timeout proxy_connect_timeout 3s; #N second server does not receive the data is automatically disconnected with the client, as this function is unwanted comment on the line #proxy_timeout 10s; # Reverse proxy URL proxy_pass myproxy; } }

 

Open cmd, enter nginx -c nginx.conf , ENTER to proceed.

Note that if you want to turn off nginx, shut the console is useless, the need to open a cmd window, enter nginx -s quit , ENTER to proceed.

Generally only modify the configuration file, does not require reboot or shutdown nginx, execution  nginx -s reload  to reload the configuration file.

 

Guess you like

Origin www.cnblogs.com/lene-y/p/11089450.html