如何在 nginx 中设置 X-Forwarded-Proto 头

直接在任何 proxy_pass 行之后添加

proxy_set_x_forwarded_proto.conf
proxy_set_header X-Forwarded-Proto $scheme;

通常 X-Forwarded-ProtoX-Forwarded-Host 一起使用,如下所示:

proxy_set_x_forwarded_host_and_proto.conf
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;

Check out similar posts by category: Networking, Nginx, Wordpress