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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM