1Panel面板
针对HTTPS反向代理出现502 Bad Gateway的问题
修正:
location ^~ / {
proxy_pass https://sg.123.com;
# 关键修正点:SSL相关配置
proxy_ssl_server_name on; # 启用SNI支持
proxy_ssl_name sg.123.com; # 明确指定SSL握手域名
proxy_ssl_verify off; # 测试时关闭证书验证(生产环境应开启)
# 修正Host头传递
proxy_set_header Host sg.123.com; # 显式设置为目标域名
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;
# 其他优化
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
# 超时配置(可选)
proxy_connect_timeout 60s;
proxy_read_timeout 60s;
add_header X-Cache $upstream_cache_status;
add_header Cache-Control no-cache;
add_header Strict-Transport-Security "max-age=31536000";
}