Question

Apache Redirect to Port 8080 - error

Hello! Please, I need your help.

In my droplet Ubuntu with Apache and Tomcat, I config 000-default.conf to redirect my domain.com from port 80 to tomcat 8080 as below:

<VirtualHost *:80>
        ProxyPreserveHost On
        ProxyPass / http://localhost:8080/
        ProxyPassReverse / http://localhost:8080/
</VirtualHost>

Works fine and the browser show me tomcat’s default page. But… I would like redirect to my JSF project (tomcat -> webapps). So I tried:

<VirtualHost *:80>
        ProxyPreserveHost On
        ProxyPass / http://localhost:8080/MyProject/
        ProxyPassReverse / http://localhost:8080/MyProject/
</VirtualHost>

or

<VirtualHost *:80>
        ProxyPreserveHost On
        ProxyPass /MyProject http://localhost:8080/MyProject/
        ProxyPassReverse /MyProject http://localhost:8080/MyProject/
</VirtualHost>

So, the browser load my login project page, but does not load the CSS, images or JSF componets. Just a simple white page, with fields to input my user, password and a button.

When I click in the button to login, the response is a error.

Note: if I complete the browser URL mydomain.com/MyProject works. But if I change the config to ProxyPassReverse / http://localhost:8080/MyProject

the page not works. What I wrote above happens.

Tks for your assistance.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
August 25, 2022

Hi @fsadvisors,

In my experience what you are trying to achieve should be done in Tomcat rather than in Apache

<VirtualHost *:80>
        ProxyPreserveHost On
        ProxyPass / http://localhost:8080/
        ProxyPassReverse / http://localhost:8080/
</VirtualHost>

This is how it should look like and then in your TomCat config, you’ll need to redirect it to use the /MyProject UR rather than using Apache for it.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up