Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have an application server located at http://foo.bar .

It needs to be accessed via http:// wibble/foo using reverse proxying.

This I've managed, however there is stuff in http:// foo.bar which references from /

EG:

/images/blah.jpg

So it's trying to get http:// wibble/images/blah.jpg instead of

http:// wibble/foo/images/blah.jpg

Any idea how I can get it to insert the /foo prefix for anything referenced from / ?

share|improve this question
    
is this http:// wibble/images/blah.jpg comming from the html page ? –  silviud Dec 20 '10 at 17:57
    
Yes, the pages refer to /images/blah.jpg so the client is requesting the file from http:// wibble/images/blah.jpg instead of http:// wibble/foo/images/blah.jpg –  Squeeb Dec 20 '10 at 18:14

2 Answers 2

mod_proxy never modifies the HTML.

Only the HTTP response headers specifically mentioned above will be rewritten. 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.

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

share|improve this answer

If you are using nginx as your front-end server, you can use the HttpSubModule to perform the substitution. Essentially, nginx should proxy the request and perform the substitution on the returned text. I do believe though, that you can't use this if you have compression on the backend (so as long as you have compression on the front-end server you should be fine):

Essentially: Nginx -> proxy to apache -> return to Nginx -> perform substitution -> compress and serve

I presume a similar module exists for Apache and other servers.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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