我无法使用Apache将HTTPredirect到HTTPS,因为我们在客户端和服务器之间有多个代理。
HTTPS在面向负载平衡器的互联网上被终止,所有其他设备(包括服务请求的Apache服务器)都使用HTTP。
我可以看到,所有Apache看起来都是HTTP链中最后一个代理的X-Forwarded-Proto。
我该如何强制它查看真正的X-Forwarded-Proto头(远程客户端)?
对于来自http后端的redirect,您在逆向代理中应该关注的唯一指令是:
ProxyPassReverse
如果redirect来自反向代理后端链,无论发送了什么内容,如果您有任何内部名称的ProxyPassReverse指令,Apache将更改位置中的主机和作为客户端的scheme(http / s)最初发送它。
好的是ProxyPassReverse可以根据需要多次指定。
例如,如果您的反向代理托pipe公共https://main.example.com,并且您有一大群后端发送redirect,如下所示:
Location: http://something.example.com/somesome Location: http://otherthing.internal.example.com/heresomething/jkjljl.whatever Location: http://deepdowninthechain.some.exampe.com/therethere/there/there
你只需要添加:
ProxyPassReverse / http://something.example.com/ ProxyPassReverse / http://otherthing.internal.example.com/ ProxyPassReverse / http://deepdowninthechain.some.exampe.com/
Apache HTTPD将返回所有这些位置标题到原来的客户端请求: https : //main.example.com/whatever …