Question

Proxy to port 8080 works partially - Apache / Tomcat

Hello! Please:

After config my domain on my Droplet I would like redirect to MyProject. I’m trying redirect the request from port 80 to tomcat 8080. In tomcat 8080 I deployed my JSF project, folder webapps.

So I did (sites-available/000-default-sites.config):

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

And works fine. The browser show me the tomcat’s default page (mydomain.com). And if complete the URL in browser as mydomain.com/Myproject, works too and MyProject run.

So I tried:

sudo a2enmod proxy
sudo a2enmod proxy_http
service apache2 restart
<VirtualHost *:80>
  ProxyPass /MyProject http://localhost:8080/MyProject/
  ProxyPassReverse /MyProject http://localhost:8080/MyProject/
</VirtualHost>

or

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

The browser display MyProject, but does not load the CSS, JSF Components or images, just display a simple white page, with fields to input my user, password and button. After click button to login, the Project does not works.

What I did wrong?

Thank you!


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 29, 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

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel