how to remove port number from URL in apache tomca

2019-06-07 20:24发布

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.

标签: java tomcat port
2条回答
手持菜刀,她持情操
2楼-- · 2019-06-07 21:10

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.

查看更多
Emotional °昔
3楼-- · 2019-06-07 21:14

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.

查看更多
登录 后发表回答