2

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.

1
  • You need to fix the path getting returned from your application. You'll have to prefix /app where necessary to the URLs it generates Commented Feb 24, 2015 at 13:33

2 Answers 2

1

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>
Sign up to request clarification or add additional context in comments.

Comments

0

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.