As a learning exercise in order to understand more about reverse proxy. I decided to use my private cloud server as a reverse proxy server and try to bypass corporate firewall (when I am at work) to allow myself to access gmail.

I have came up with the following Proxy configuration (please dont mind the square brackets):

SSLProxyEngine on
ProxyRequests Off
ProxyVia Off

[Proxy *]
    Order deny,allow
    Deny from all
    Allow from xxx.xxx.xxx

ProxyPreserveHost On

ProxyPass /qqq https://www.google.com/accounts/ServiceLogin?service=mail
ProxyPassReverse /qqq https://www.google.com/accounts/ServiceLogin?service=mail

ProxyPass /qqqqq http://mail.google.com/mail
ProxyPassReverse /qqqqq http://mail.google.com/mail

The outcomes of the above configuration as follows:

  1. When I navigate to myserver.com/qqq, the backend server (Google) simply changes URL and redirects me to google.com. Although I have "ProxyPreserveHost On"

  2. When I navigate to myserver.com/qqqqq, Google does 301 back to my proxy server, which redirects me again to Google and I end up in the loop.

I have read a number of posts here at stackoverflow, but could not extract any helpful info from them:




My questions here are:

  1. How to prevent Google from changing the URL, and instead transparently display content

  2. What can I do in order not end up in 301 loop between my proxy server and Google

If you think I have missed/omitted/misunderstand something, please do let me know

Thank you, Alex

  • Probably accounts.google.com sets a cookie (you're logged in), redirects you to mail.google.com, which can't see the cookie and redirects you back to the login page
    – JCH2k
    Oct 21, 2016 at 7:48

1 Answer 1


I have done that by the following code. You can try it...

    ProxyPreserveHost On
    <Proxy *>
            AddDefaultCharset off
            Order deny,allow
            Deny from all
          Allow from all

            ProxyPass /google http://www.google.com/
            ProxyHTMLURLMap http://www.google.com /google

    <Location /google>
            ProxyPassReverse /
            ProxyHTMLInterp On
            ProxyHTMLURLMap  /      /google
            RequestHeader    unset  Accept-Encoding

You must log in to answer this question.