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