HARA
HARA

Reputation: 21

apache reverse proxy configuration

I am trying to configure reverse proxy for one application. Am using apache 2.2 web server below are my configuration rules

ProxyRequests off

ProxyPreserveHost on

ProxyPass /app/ (http://11.11.111.11:123/)

ProxyPassReverse /app/ http://11.11.111.11:123/

Problem: When i hit the url of my local server like myserver.co.in/app/ first page is coming (application log in page). after that application is redirecting to url myserver.co.in/home/index.html and redirection failed. since "/app/" part is missing in the url.

Can any one help me to fix this issue. thanks in advance.

Upvotes: 2

Views: 2908

Answers (2)

Emad Omar
Emad Omar

Reputation: 768

You can either modify your app to add the /app prefix or use mod_proxy_html.

The following is quoted from "When ProxyPass and ProxyPassReverse aren’t enough" and is modified to suite what you've asked.

In a nutshell, mod_proxy_html allows you to rewrite html, javascript & css so that the URLs can cleanly go through your reverse proxy. This means that the backend application responds with

<script src="/script/application.js" type="text/javascript"></script>

mod_proxy_html will converted it to

<script src="/app/script/application.js" type="text/javascript"></script>

To get this to work, add the following to httpd.conf

ProxyPass /app/ (http://11.11.111.11:123/)
ProxyPassReverse /app/ http://11.11.111.11:123/
ProxyHTMLURLMap http://11.11.111.11:123/ /app/

<Location /app/>
  ProxyHTMLEnable On
  ProxyPassReverse http://11.11.111.11:123/
  SetOutputFilter proxy-html
  ProxyHTMLURLMap / /app/
  ProxyHTMLURLMap /app /app
</Location>

Upvotes: 1

Rhys Clarke
Rhys Clarke

Reputation: 87

because apache dosnt know you want a different page, you need to set working directory for this virtual host to the directory where you app is.

For example,

DocumentRoot "/www/example2"

so using your config would be

<VirtualHost *:80>
    DocumentRoot "/www/example2"
    ProxyRequests off
    ProxyPreserveHost on
    ProxyPass /app/ (http://11.11.111.11:123/)
    ProxyPassReverse /app/ http://11.11.111.11:123/
    # Other directives here
</VirtualHost>

Upvotes: 0

Related Questions