Home >Backend Development >PHP Tutorial >nginx does load balancing configuration
I only write down the main configuration here. As for other opening logs, setting weights and so on, if you are interested, you can figure it out by yourself.
The following configuration listens to the 80port of this machine and provides services for the domain name www.baidu.com.
Effect: Requests from www.baidu.com are forwarded to 192.16.0.1:80 on average, 127.0.0.1:8080 On both services. (nginx.conf)
In addition: The configuration of Taobao tengine is basically the same as this
upstream main {
server 192.16.0.1:80; //This is used for configuration The path to tomcat, including the port, can also be configured with weights here.
Server 127.0.0.1:8080;
} Listen 80; It is the listening port, which is the port number of the URL when accessing.
server_name www.baidu.com;
# Increase this if you want to upload larger attachments
client_max_body_size 20m;# individual nginx logs for this vhost
access_log /var/log/nginx/store_access.log;
error_log /var/log/nginx/store_error .log;
location / {
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host teststore.boldseas.com;
#for proxy to IIS proxy_set_header _set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://main;
}The name of main is the same, you need to pay attention to
proxy_redirect off; The above introduces the load balancing configuration of nginx, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.