10

I'm trying to configure Apache on Centos 6 to proxy and reverse proxy traffic to an http server of a third party provider.

The setup should work like this: https://mydomain.com/proxy/ proxies all trafic transparently to http://thirdparty.com/app/

The issue I'm having is any request made to https://mydomain.com/proxy/ gets a 301 redirect in response.

These are all of the proxy related options in my 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>
james_t
  • 203
  • 1
  • 2
  • 5

1 Answers1

15

We have a similar setup and are using this (of course you need to load before mod_proxy, mod_ssl and 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/
Huygens
  • 1,708
  • 3
  • 20
  • 36
  • I found one bug in that I was using http://thirdparty.com which redirects to http://www.thirdparty.com. However my original configuration did not work with this either, yours did. Thanks. – james_t Mar 08 '13 at 18:16
  • 1
    Note that `SSLProxyEngine` is not necessary here - that would be needed if you proxied to `httpS://thirdparty.com/` – Piskvor left the building Oct 19 '17 at 07:50
  • 1
    @Piskvor indeed after checking the documentation again, it is not necessary in that case. I will update the answer. Thank you for pointing that out. – Huygens Oct 19 '17 at 09:03