nginx 4層代理配置


1、nginx 從1.9.0版本開始支持四層代理,但做四層代理時 編譯需要添加  --with-stream模塊

# ./configure --prefix=/usr/local/nginx--user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-file-aio --with-stream

2、nginx配置文件

user www;
worker_processes 2;
events {
worker_connections 1024;
}
stream                                          #stram模塊 和http模塊是一同等級;做四層代理時需要添加上這個模塊;
      server {
          listen 30028;                          #30028端口將以4層TCP協議方式轉發至后端app_sever;
          proxy_pass app_server;
      }
      upstream app_server{
          server 172.22.0.44:30028;

          server 172.22.0.45:30028;
      }
}
http {
      include mime.types;
      default_type application/octet-stream;
      sendfile on;
      keepalive_timeout 65;
      server {
               listen 80;
               server_name localhost;
               location / {
                    root html;
                    index index.html index.htm;
               }
               error_page 500 502 503 504 /50x.html;
               location = /50x.html {
                   root html;
               }
     }
}


免責聲明!

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



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