
我有一個NGINX監聽埠441,SSLH監聽埠:441(https),442(ssh),最後STUNNEL監聽埠443轉送到SSLH(埠2243)。
隧道配置:
pid = /var/run/stunnel.pid
cert = /etc/letsencrypt/live/f1.example.com/fullchain.pem
key = /etc/letsencrypt/live/f1.example.com/privkey.pem
[sslh]
accept = 443
connect = 127.0.0.1:2243
SSLH 設定:
DAEMON_OPTS="--user sslh --listen 127.0.0.1:2243 --ssh 127.0.0.1:442 --ssl 127.0.0.1:441 --pidfile /var/run/sslh/sslh.pid"
NGINX 配置:
server {
server_name f1.example.com;
listen 441;
access_log /var/log/nginx/f1.access;
error_log /var/log/nginx/f1.error;
location /admin/ {
proxy_pass http://127.0.0.1:10000/;
proxy_set_header Host $host;
proxy_redirect http://$host:10000/ /admin/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 80;
return 302 https://$host$request_uri;
}
正如你所看到的,我正在 /admin/ 路徑中運行一個 WEBMIN 應用程序,並使用 NGINX 進行反向代理。我的問題是,當我在瀏覽器中輸入 f1.example.com/admin 時,它會重定向到 HTTPS 版本,即https://f1.example.com/admin。
成功登入後重定向到http://f1.example.com:441/admin/sysinfo.cgi?xnavigation=1它位於 HTTP 中,連接埠為 441(我想知道如何在此處插入連接埠號碼)。頁面載入正常,但不是 HTTPS。我必須手動刪除連接埠號碼並按 Enter 鍵才能將其升級到 HTTPS。
我怎麼能讓它順利地與 HTTPS 一起工作?我需要對 NGINX conf 檔案進行哪些更改?我覺得我在這裡錯過了一些東西。
答案1
port_in_redirect off;
將其添加到 nginxconf 中,現在效果非常好!