nginx 反代+负载均衡

直接上配置文件:

/etc/nginx/sites-enabled/xx_facade.conf

nginx在80端口监听  www.test1.com www.test2.com这两个域名,并把请求转发到server1:8900和 server2:8900

 

upstream jdy_cluster {
        server server1:8900;
        server server2:8900;
}

server {
    listen       80;
    server_name  www.test1.com www.test2.com;

    access_log /var/log/nginx/jdy_facade.log;
    error_log  /var/log/nginx/jdy_facade.err;

    gzip on;
    gzip_proxied any;
    gzip_types text/plain text/css application/javascript application/xml application/json application/x-javascript;
    gzip_min_length 1400;

    location / {
        proxy_pass http://jdy_cluster;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Srv-Addr $scheme://$host:$server_port;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

  

 

posted @ 2016-03-14 16:21  _NullPointer  阅读(524)  评论(0编辑  收藏  举报