How to have Apache server port 8080 display content from localhost:3080

423 Views Asked by At

So I have an application the is bound to localhost:3080. When I locally visit "localhost:3080" the application displays in the browser.

I also have an apache server setup listening to the publicIP:8080.

When I visit the publicIP from the outside world, publicIP:8080 loads up.

How can I have it so that when I visit publicIP:8080, the contents of localhost:3080 are displayed onto it?

Is there a way to forward the contents of localhost:3080 to publicIP:8080?

2

There are 2 best solutions below

0
On

I assume your application at localhost:3080 acts as a http server. Then you would simply

ProxyPass "/" "http://localhost:3080/"

Generally its better to use ProxyPass to handle only special locations

<Location "/myCoolApp/">
    ProxyPass "http://localhost:3080/"
</Location>

Then if you request http://publicIP:8080/myCoolApp/XYZ your application @3080 will receive the request on URL /XYZ.

0
On

You can create an apache proxy.For example :

<VirtualHost *:8080>

    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:3080/
    ProxyPassReverse / http://127.0.0.1:3080/

</VirtualHost>

You will also need to do :

a2enmod proxy
a2enmod proxy_http
service apache2 restart

See more informations there : https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension