NGINX配置参考

pcre 编译安装 nginx

在nginx.conf里添加 include vhost/*;

conf/vhost/test.conf

upstream admin {

ip_hash;

server 127.0.0.1:8080;

server 127.0.0.1:8081;

}

server {

                listen       80;

                server_name admin.xxx.dev;

                location / {

                        proxy_next_upstream http_502 http_504 http_404 error timeout invalid_header;

                        proxy_set_header Host $host;

                        proxy_set_header X-Real-IP $remote_addr;

                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

                        proxy_pass http://admin;

                }

                access_log  /home/wwwlogs/admin.xxx.dev.log  access;

 }

upstream backend_server {

    server 192.168.61.1:9080 max_fails=2 fail_timeout=10s weight=1;

    server 192.168.61.1:9090 max_fails=2 fail_timeout=10s weight=1;

}

server {

    ......

    location /test {

       proxy_connect_timeout 5s;

       proxy_read_timeout 5s;

       proxy_send_timeout 5s;

       proxy_next_upstream error timeout;

       proxy_next_upstream_timeout 6s;

       proxy_next_upstream_tries 2;

       proxy_pass http://backend_server;

       add_header upstream_addr $upstream_addr;

    }

}

相关推荐