centos上nginx转发tcp请求

下载最新版nginx

> wget http://nginx.org/download/nginx-1.17.1.tar.gz

解压缩

> tar zxvf nginx-1.17.1.tar.gz

> cd nginx-1.17.1

配置

> ./configure --with-stream --with-stream_ssl_module

构建

> make

> make install

修改配置文件

> vi /usr/local/nginx/conf/nginx.conf

stream {
  upstream server_vertica {
    server 172.16.1.1:5433;
    server 172.16.1.2:5433;
    server 172.16.1.3:5433;
  }

  server {
    listen 9501;
    proxy_connect_timeout 30s;
    proxy_timeout 3600s;
    proxy_pass server_vertica;
  }

}

启动nginx

nohup /usr/local/nginx/sbin/nginx &

原文地址:https://www.cnblogs.com/lavezhang/p/11096813.html