美文网首页
ngnix反向代理服务和负载均衡

ngnix反向代理服务和负载均衡

作者: shawbs | 来源:发表于2017-11-22 11:28 被阅读0次

    编辑nginx.conf


    nginx实现负载均衡

    upstream nodejs {
        server 127.0.0.1:8091;
        server 127.0.0.1:3001;
        server 47.x.x.x:3000;
        keepalive 64;
    }
    
    server {
        listen 80;
        server_name xxx.com;
        access_log logs/node.test.log;
        location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host  $http_host;
            proxy_set_header X-Nginx-Proxy true;
            proxy_set_header Connection "";
            proxy_pass      http://nodejs;
    
        }
    
    }
    

    反向代理

    server {
        listen 80;
        server_name aaa.com;
       server_name bbb.com;
       server_name ccc.com;
        access_log logs/node.test.log;
        location ^~ /aaa{
            proxy_pass      http://aaa.com;
        }
        location ^~ /bbb{
            proxy_pass      http://bbb.com;
        }
       location ^~ /ccc{
            proxy_pass      http://ccc.com;
        }
    
    }
    

    相关文章

      网友评论

          本文标题:ngnix反向代理服务和负载均衡

          本文链接:https://www.haomeiwen.com/subject/nxenvxtx.html