0

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 / ?

Squeeb
  • 172
  • 1
  • 13
  • 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 Answers2

1

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

Mark Wagner
  • 18,019
  • 2
  • 32
  • 47
0

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.

cyberx86
  • 20,805
  • 1
  • 62
  • 81