Apache-2.2

使用 apache 作為 HTTPS 到 HTTP 代理

  • October 19, 2017

我正在嘗試在 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>

我們有一個類似的設置並且正在使用它(當然你需要在 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/

引用自:https://serverfault.com/questions/486042