/data/nginx-1.8.1/conf/nginx.conf文件
修改如下:
server {
listen 80;
server_name localhost1;
#charset koi8-r;
#
# #access_log logs/host.access.log main;
#
location / {
# root html;
# index index.html index.htm;
proxy_pass http://192.168.1.39:8080;
}
}
server {
listen 80;
server_name localhost2;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
# root html;
# index index.html index.htm;
proxy_pass http://192.168.1.39:8081;
}然后访问 http://localhost:80 就可以访问 8080 和 8081 2个端口来回负载
原文:http://blog.51cto.com/hackerxian/2113451