![使用 apache 作为 HTTPS 到 HTTP 代理](https://linux22.com/image/799835/%E4%BD%BF%E7%94%A8%20apache%20%E4%BD%9C%E4%B8%BA%20HTTPS%20%E5%88%B0%20HTTP%20%E4%BB%A3%E7%90%86.png)
我正在尝试在 Centos 6 上配置 Apache 以代理和反向代理流量到第三方提供商的 http 服务器。
设置应像这样工作:
https://mydomain.com/proxy/
将所有流量透明地代理到
http://thirdparty.com/app/
我遇到的问题是任何请求都会https://mydomain.com/proxy/
得到 301 重定向响应。
这些是我所有的代理相关选项VirtualHost
SetOutputFilter proxy-html
ProxyHTMLExtended On
ProxyRequests Off
SSLProxyEngine On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /proxy/ http://thirdparty.com/app/
<Location /proxy/>
ProxyPassReverse /
ProxyHTMLEnable On
ProxyHTMLURLMap http://thirdparty.com/app/ /proxy/
ProxyHTMLURLMap / /proxy/
</Location>
答案1
我们有一个类似的设置并正在使用它(当然你需要在 mod_proxy、mod_ssl 和 mod_proy_http 之前加载):
ProxyRequests Off
# SSLProxyEngine On # only required if the proxied service would be HTTPS as well
# Meaning if we would reverse proxy https://thirdparty.com/app/
# Thanks @Piskvor for the clarification.
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /proxy/ http://thirdparty.com/app/
ProxyPassReverse /proxy/ http://thirdparty.com/app/
<Location /proxy/>
ProxyPassReverse /
Order deny,allow
Allow from all
</Location>
Header edit Location ^http://thirdparty.com/app/ https://thirdparty.com/app/