how to remove port number from URL in apache tomcat if connector port is 8081

19,519

Solution 1

You should consider using a proxy on your server. There is a really good tutorial at apache.org, using an Apache Web Server.

http://tomcat.apache.org/tomcat-7.0-doc/proxy-howto.html

This enables you to connect to your server via port 80, which is not printed in the url bar of your browser.

Solution 2

I saw answer above and struggled a bit, so thought of putting up an example since I was on ubuntu, so I had to change apache2.conf file in /etc/apache2/ You can find your apache2.conf file or httpd.conf as per your OS

I added following rules -

    <VirtualHost *:80>  
    ServerName sushant.com
    ServerAlias www.sushant.com

    ProxyRequests On

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

    <Location />
            ProxyPass http://localhost:7777/
            ProxyPassReverse http://localhost:7777/
    </Location>

 </VirtualHost>
 <VirtualHost *:8081>
    ServerName  sushant.com
    ServerAlias www.sushant.com

    ProxyRequests on

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

    <Location />
            ProxyPass http://localhost:8081/
            ProxyPassReverse http://localhost:8081/
    </Location>

  </VirtualHost>

So, now it works both with and without the port.

Share:
19,519
Sushant Srivastava
Author by

Sushant Srivastava

Updated on July 14, 2022

Comments

  • Sushant Srivastava
    Sushant Srivastava almost 2 years

    I am running multiple instance of tomcat on my linux machine. so there are more than one connector ports for different instance like 8080,8081,8082. I want to remove port number from URL.

    For example :-
    Current url : - www.sushant.com:8081/
    Needed :-www.sushant.com/
    please suggest me how can i do this.
    Thanks.