2

I'm facing an issue when trying to configure apache 2.2 as a proxy reverse.

I've an application running at my backend server http://internal.mydomain.com/App1/, for now this URL is going to be the $URL, because I'm a new guy here and I'm not able to post more than 2 URL on my first post.

If on my proxy server I use the following configuration everything work fine

UseCanonicalName off
UseCanonicalPhysicalPort off
ProxyPreserveHost On

ProxyPassReverseCookieDomain internal.mydomain.com external.mydomain.com

ProxyPass /App1/ $URL connectiontimeout=10 timeout=60
ProxyPassReverse /App1/ $URL

The URL to access is external.mydomain.com/App1/

But my boss wants to have a different URL for this, something like external.mydomain.com/my/app1/, so I tried with the following configuration

UseCanonicalName off
UseCanonicalPhysicalPort off
ProxyPreserveHost On

ProxyPassReverseCookieDomain internal.mydomain.com external.mydomain.com

ProxyPass /my/app1/ $URL connectiontimeout=10 timeout=60
ProxyPassReverse /my/app1/ $URL

That should work but when I loading the webpage, the backend server is answering with this

Cache-Control: private
Content-Type: text/html; charset=utf-8
Location: /App1/StartPage.aspx
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-UA-Compatible: IE=edge
Date: Tue, 16 Aug 2016 21:25:01 GMT
Content-Length: 144

//<html><head><title>Object moved</title></head><body>
//<h2>Object moved to <a href="/App1/StartPage.aspx">here</a>.</h2>
//</body></html>

So, my question is, is there any way to rewrite on the fly anything coming from the backend ?

1 Answers1

0

ProxyPassReverse should enable you to correct any Location, Content-Location or URI HTTP headers that are returned by the back end server.

These can get a little tricky when, as your boss wants, you ProxyPass using a different URI path to the deployment path of the underlying application. It is far more stable to deploy the underlying app under the new path (/my/app1/ in this case). If your boss insists, and you cannot change the deployment path then you will need a different ProxyPassReverse line. Something like the following:

ProxyPass /my/app1/ http://internal.mydomain.com/App1/
ProxyPassReverse /App1/ /my/app1/

If you have links in the HTML from the back end server that need modifying then you would either need to upgrade to Apache httpd v2.4 and use mod_proxy_html or hack something together with mod_sed or mod_substitute to fix offending URLs.

Unbeliever
  • 2,336
  • 1
  • 10
  • 19