使用apache作为HTTPS到HTTP代理


10

我正在尝试在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>

Answers:


15

我们有一个类似的设置,并且正在使用它(当然,您需要在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/

我发现一个错误是因为我使用的是thirdparty.com,它重定向到thirdparty.com。但是,我的原始配置也不适用于您,您的也可以。谢谢。
james_t

1
请注意,SSLProxyEngine在这里没有必要-如果你代理到将需要httpS://thirdparty.com/
Piskvor离开大楼

1
实际上,在再次检查文档后,@ Piskvor确实没有必要。我将更新答案。感谢您指出这一点。
惠更斯(Huygens)
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.