nginx負載均衡配置

修改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;
        }

然後訪問 http://localhost:80   就可以訪問 8080   和 8081 2個端口來回負載

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章