Forum Moderators: phranque

Message Too Old, No Replies

proxy help needed to get around redirection

mod_proxy_html not handing redirects

         

dsegel

5:16 pm on Nov 17, 2010 (gmt 0)

10+ Year Member



I'm having a problem getting a proxy to an internal server to work properly.

The external site is running apache 2.2.14 (Ubuntu).

The internal site I'm trying to proxy to has an authentication page that asks for username and password. I get that part to show up fine, but after submitting the credentials the internal site tries to redirect the user to the internal address, which fails because it's behind a firewall (and it's an internal private domain).

This is how I have it set up:


ProxyRequests Off
ProxyHTMLExtended On

ProxyPass /help http://help.shs.ucd
<Location /help/>
ProxyPassReverse /
SetOutputFilter INFLATE;proxy-html;DEFLATE
#ProxyHTMLURLMap http://help.shs.ucd/ /help
ProxyHTMLURLMap / /help/
ProxyHTMLURLMap /images /help/images
ProxyHTMLURLMap /favicon.ico /help/favicon.ico
ProxyHTMLURLMap /help /help
</Location>


I want the entire internal site to be proxied under [site.domain.com...] I will eventually have other internal sites proxied under other directories as well.

What happens now is the login page shows up, and after entering credentials it tries to redirect the user to [help.shs.ucd,...] which is internal, behind a firewall, and not a public domain so it fails in many ways. I have mod_proxy_html enabled, but it doesn't seme to handle the redirect.

Is there some way I can use mod_rewrite to change the redirect request coming back? I've been messing with it for a week with no luck.

jdMorgan

7:29 pm on Nov 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not familiar with mod_proxy_html, but look to see if it has a function similar to the "ProxyPassReverse" directive of Apache mod_proxy:

This directive lets Apache adjust the URL in the Location, Content-Location and URI headers on HTTP redirect responses. This is essential when Apache is used as a reverse proxy (or gateway) to avoid by-passing the reverse proxy because of HTTP redirects on the backend servers which stay behind the reverse proxy.

Jim

dsegel

8:29 pm on Nov 17, 2010 (gmt 0)

10+ Year Member



I am using ProxyPassReverse; it's inside the Location statement. I've tried it the regular way as well and it still doesn't work:


ProxyPass /help http://help.shs.ucd
ProxyPassReverse /help http://help.shs.ucd


It's actually worse that way because the internal site uses a lot of absolute paths (like /scripts/include.js). If I proxied at the root of the external site that would help somewhat, but since I want to set up proxies for several internal sites I need them to all be under their respective directories, like /help in this case.

From the mod_proxy docs:
Apache will not rewrite other response headers, nor will it rewrite URL references inside HTML pages. This means that if the proxied content contains absolute URL references, they will by-pass the proxy. A third-party module that will look inside the HTML and rewrite URL references is Nick Kew's mod_proxy_html.

The problem is that mod_proxy only seems to rewrite html content, not redirects.

jdMorgan

2:06 am on Nov 30, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mod_proxy only rewrites requested URL-paths. It works as a URL request is received by the server, and has no effect on the content sent back to the client by the server. If you need to modify pages on the fly, look into Apache 2.x filters.

Also, be aware that it is the client (e.g a browser or search engine) that resolves server-relative or page-relative links in HTML pages to the canonical URLs which muse be requested from a server.

For server-relative links sucah as "/scripts/include.js, this is done by pre-pending the hostname shown in the browser address bar. For page-relative links such as "scripts/include.js", it is done by removing the current 'page' URL-path-part from the URL in the address bar, and then appending the relative link path.

Jim