修改nginx安装目录:
/usr/local/nginx/conf/nginx.conf文件
修改如下:
#user nobody;
worker_processes auto;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
worker_rlimit_nofile 65535;
upstream java { server 192.168.1.39:8080; server 192.168.1.39:8081;} server { listen 80; server_name 192.168.1.39; #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; proxy_pass http://java; }
然后访问 就可以访问 8080 和 8081 2个端口来回负载