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>

1 Answer 1

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/
3
  • I found one bug in that I was using thirdparty.com which redirects to thirdparty.com. However my original configuration did not work with this either, yours did. Thanks.
    – james_t
    Mar 8, 2013 at 18:16
  • 1
    Note that SSLProxyEngine is not necessary here - that would be needed if you proxied to httpS://thirdparty.com/ Oct 19, 2017 at 7: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, 2017 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.