Nginx端口负载

upstream www.abc.com {
server localhost:7001 weight=1;
server localhost:7002 weight=1;
}
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm index.php;
proxy_pass http://www.abc.com;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 7001;
server_name localhost;
location / {
root html;
index index.html index.htm index.php;
       proxy_pass http://localhost:7001; 
}
}
server {
listen 7002;
server_name localhost;
location / {
root html;
index index.html index.htm index.php;
        proxy_pass http://localhost:7002;
}
}

总结:其实就是指定多个server 通过upstream 来进行分配
posted @ 2021-01-22 09:32  绿茶GT  阅读(151)  评论(0)    收藏  举报