how to access tomcat server from outside network

141 Views Asked by At

My local servers IP is 19.xxxxx. My application runs on TOMCAT using local IP 19.xx.xx.xx.:8090

I want outside users reach this IP by typing xxx.xxx.com:8090

DNS and firewall settings has done by IT.

How will i change server.xml in Tomcat?

1

There are 1 best solutions below

0
Bella FSM On

You need to set up a reverse proxy and properly configure DNS.

Make sure the domain servername.com points to the IP address of your local machine where Tomcat is running. Do this by adding an A record in your DNS configuration.

The redirection you're looking for can be done by using a reverse proxy, like Apache HTTP Server or Nginx.

You did not indicate what environment your local machine is. Here is an example of installing and setting up a reverse proxy with Apache on Debian or Ubuntu:

sudo apt update

sudo apt install apache2

Enable proxy modules:

sudo a2enmod proxy

sudo a2enmod proxy_http

Edit the Apache configuration which should be located at /etc/apache2/sites-available/000-default.conf. Add the following:

<VirtualHost *:8080>

    ServerName servername.com

    ProxyRequests Off

    ProxyPreserveHost On

    ProxyPass / http://localhost:8080/

    ProxyPassReverse / http://localhost:8080/

</VirtualHost>

Save the file and exit.

Restart Apache:

sudo systemctl restart apache2

If you have a firewall make sure to configure to allow port 8080. Here is an example for Firewalld:

sudo firewall-cmd --add-port=8080/tcp --permanent

sudo firewall-cmd --reload

This should create the redirect you want.