----------------使用nginx向外暴露一個端口而內部進行轉發並只使用本機的多個端口------------------
此情況適合被限制只能訪問唯一一個端口的場景,
例如公司限制了用戶只能訪問唯一的80端口。
之前使用過sslh, 都沒有實現,最後嘗試 nginx 可以實現。
server { listen 80; server_name www.xuesong0323.cn; #access_log logs/host.access.log main; # 下面location 中可以配置多個ip 多個端口 ,或者同個ip 多個端口 location / { pass_pass http://127.0.0.1:6666/; #向配哪裏配哪裏,後面一致就好了 index index.html index.php 1.php 1.html; //如果只是提供服務可以不用寫具體的頁面入口 } location /string { pass_pass http://127.0.0.1:8888/string;#向配哪裏配哪裏,後面一致就好了 index index.html index.php 1.php 1.html; } error_page 500 502 503 504 /50x.html;#錯誤頁面 location = /50x.html { #錯誤頁面路徑 root /home/***/;#這個一般不會改,除非你覺得自己寫的的比較好看= =,我這個是改過的 } location ~ \.php$ { root /home/***/; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name; include fastcgi_params; } }