0

This is probably a simple problem but I just can't seem to solve it! I have a website running 2 Apache Tomcats on different ports (e.g. 8080, 8085). However since my customers cannot access specific ports (their firewalls prevent this) they can only access my machine from port 80.

So I got the following redirects to work:

aServer.com/App1 redirects to aServer.com:8080/App1
aServer.com/App2 redirects to aServer.com:8085/App2

using the following httpd.conf file:

<VirtualHost *:80>
    ProxyPass        /App1 http://<server ip address>:8080/App1
    ProxyPassReverse /App1 http://<server ip address>:8080/App1
    ProxyPass        /App2 http://<server ip address>:8085/App2
    ProxyPassReverse /App2 http://<server ip address>:8085/App2
</VirtualHost>

However if I want to deploy an application as a ROOT webapp in Tomcat, then I can't get the redirect to work properly. I modified httpd.conf to:

    ProxyPass        /App2 http://<server ip address>:8085
    ProxyPassReverse /App2 http://<server ip address>:8085

and now only the index.html page is returned and every dependency from the webpage (e.g. tomcat.css, tomcat.png) results in a not found error ( NetworkError: 404 Not Found - http://myServer/tomcat.css)

Can anyone explain what I am doing wrong?

Thanks,

Phil

krissi
  • 3,387
  • 1
  • 19
  • 22
Phil
  • 109
  • 2
  • 8

1 Answers1

0

Unless you application explicitly supports proxies, you usually need to matching the proxy path with the context path.

http://myserver/tomcat.css is a request that will attempt to be fulfilled on your Apache document root since / is not being proxied to Tomcat. You'll need to do one of the following (options ranging from safe to lazy):

  • proxy Apache root to the Tomcat root,
    If you are not going to run both applications in the same container, make sure you put your ProxyPass directives in the correct order

  • modifiy the original index.html page in Tomcat to take into account the path change caused by the Proxy,
    You'll have to redo this everytime you re-deploy.

  • provide a rewrite for ALL the resources to the proxied path
    You'll have to redo this everytime a re-deploy changes the required resources.

krissi
  • 3,387
  • 1
  • 19
  • 22
nickrak
  • 116
  • 1