1. 程式人生 > >nginx upstream

nginx upstream

nginx轉發http和tcp

http轉發

upstream goforit_201
{
    server 172.168.10.10:201;
}

server {
        listen 201;
        server_name 192.168.0.100;
        access_log  logs/access_201.log main;
        location / {
            proxy_pass http://goforit_201;
            allow 192.168.230.0/24;
            deny all;
        }
}

tcp轉發需要新增stream模組

--prefix=/usr/local/data/nginx —user=goforit —group=goforit --with-pcre --with-http_stub_status_module --with-http_ssl_module --with-stream --with-stream_ssl_module


stream {
        server {
                listen 200;
                proxy_pass goforit_200;
                allow 192.168.230.0/24;
                deny all;
        }
        upstream goforit_200
        {
                server 172.168.10.10:200;
        }
}