Not sure if this is the right stack exchange to post this. If there is a better place please redirect me - thanks.
I enabled these lines in httpd.conf:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Then I added these lines:
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /goo http://google.ca
ProxyPassReverse /goo http://google.ca
If I open up my browser and go to this URL:
http://localhost/goo
I get redirected to:
http://www.google.ca
I expected that mod_proxy would act like a proxy and not just redirect to google. I would expect that my browser should NOT know that google.ca exists and should only know about the existance of the proxy server.
- What is going on here?
- Is this not what mod_proxy was designed for?
- Is there something else that I should be using instead?
Well, let's take a look at
http://google.ca
:And there's your redirect. Google does this on
google.com
,google.ca
, and probably others.Sure. It's doing exactly what you asked it to do...it's fetching content from
http://google.ca
and returning it verbatim to your client.If you really want to act like a generic forward proxy on a particular URL, you're probably going to need to investigate mod_proxy_html, which can be used to rewrite links in content fetched from a remote server.
But in general, it's really hard to prevent a remote site from performing this sort of redirect (because even if you rewrite links in the
Location
header, in<A>
tags, and elsewhere, you may miss some Javascript or something...)mod_proxy will in fact rewrite "Location," "Content-Location," and "URI" headers on HTTP redirect responses. As explained in larsks' answer the 301 google is doing causes
to be ineffectual because the redirect to www.google.ca does not match.
You could try adding
but it isn't clear what you are trying to accomplish.