1
votes

My intent is very simple, I would like to type example.com and be redirect to example.com:8080/myapp

example.com:8080/myapp is a java/tomcat app.

   <VirtualHost *:80>
    ServerName example.com

    ProxyRequests Off
    <Proxy *>
            Order deny,allow
            Allow from all
    </Proxy>

    ProxyPass / http://example.com:8080/myapp/
    ProxyPassReverse / http://example.com:8080/myapp/

    <Location />
            Order deny,allow
            Allow from all
    </Location>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    LogLevel info

    CustomLog ${APACHE_LOG_DIR}/access.log combined

   </VirtualHost>

And the result is when I type http://example.com it's redirected to example.com:8080/myapp/myapp

My file server.xml from Tomcat has the follow instruction:

  Connector port="8080" protocol="HTTP/1.1"
       connectionTimeout="20000"
       URIEncoding="UTF-8"
       proxyPort="80" proxyName="example.com"

What I am missing?

1

1 Answers

1
votes

Proxypass change the server name part, but not the ressource id one:

Instead of :

ProxyPass / http://example.com:8080/myapp/
ProxyPassReverse / http://example.com:8080/myapp/

Use:

ProxyPass / http://example.com:8080/
ProxyPassReverse / http://example.com:8080/

Edit:

Then add:

RewriteEngine on
RewriteRule ^/$ /myapp [PT]