: This article describes how to configure reverse proxy for Nginx. For more information about PHP tutorials, see. 1, first create a configuration file,/etc/nginx/sites-enabled/reverse-proxy.conf
The content is as follows, and each line must end with a semicolon
Upstream monitor_server {# here is to use server load balancer so that multiple ip addresses can provide the same service. weight is the weight, server 10.10.12.203: 8080 weight = 2; server 10.12.202: 8080 weight = 4;} server {listen 8081; server_name www.xxx123.com; # reverse domain name proxy. different domain names direct to the same ip address, go through nginx, it also provides network services to different internal ip addresses. "www" does not omit location/{proxy_redirect off; proxy_set_header Host $ host; proxy_set_header X-Real-IP $ remote_addr; proxy_set_header X-Forwarded-For $ response; proxy_pass http: // monitor_server ;}} server {listen 8081; server_name localhost; location/{proxy_redirect off; proxy_set_header Host $ host; proxy_set_header X-Real-IP $ remote_addr; proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for; proxy_pass http: // 10.12.203: 8080 ;}}
2. include the preceding configuration file to nginx. conf.
Edit/etc/nginx. conf and add a sentence to http {}, for example
Include/etc/nginx/mime. types;
Default_type application/octet-stream;
Add the following sentence to the two rows:
Include/etc/nginx/sites-enabled/reverse-proxy.conf;
In this way, you can reference the reverse proxy configuration file, and then restart: service nginx restart
3. test
My test client is windows and the ip address is 10.10.12.73. The nginx server is in Ubuntu and the ip address is 10.10.2.176.
Open the c: \ windows \ System32 \ drivers \ etc \ hosts file, and add the following at the end:
10.10.2.176 www.xxx123.com
10.10.2.176 is the ip address of the nginx server. you can enter www.xxx123.com in the browser.
The above describes how to configure the reverse proxy for Nginx, including some content, and hope to help those who are interested in the PHP Tutorial.