时间: 2023-11-03 【学无止境】 阅读量:共373人围观
简介 后端服务器是http,跳转的proxy_pass 会将url改为http://www.zhangfuxiang.com/。如果直接写proxy_pass https://www.zhangfuxiang.com/;会因为后端没有https提供服务导致400报错,那么只需要强制再把http 跳转成https即可.修改conf/nginx.conf的以下配置
关键代码
proxy_redirect http:// https://;
server { listen 443; server_name www.zhangfuxiang.com; charset utf-8; access_log logs/host.access.log main; location / { proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host:$server_port; proxy_pass http://127.0.0.1:5000/; proxy_redirect http:// https://; } }