nginx反向代理配置(nginx.conf+proxy_set_header)

转载:https://blog.csdn.net/bjsunwei/article/details/62231209

 

     location / {

            proxy_pass http://test;

            proxy_set_header Host $host:$server_port;

            proxy_set_header X-Real-IP $remote_addr;

            proxy_set_header X-Real-PORT $remote_port;

            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        }

这个是http协议

nginx 编译时添加 tcp模块

 

这个是tcp 协议

tcp {
      upstream mysql{
      server 10.10.10.17:3306 weight=1;
      server 10.10.10.18:3306 weight=1;
      #check interval=3000 rise=2 fall=5 timeout=1000;
      }
      server {
      listen 3306;
      proxy_pass mysql;
       }
}

nginx1.90对TCP协议的代理并不是默认开启的,需要在编译的时候配置 --with-stream 参数

./configure --prefix=/usr/local/nginx  --with-stream

 

posted @ 2018-03-31 17:03  随风而逝,只是飘零  阅读(2613)  评论(0编辑  收藏  举报