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

若如初见. 提交于 2019-12-12 10:12:09

问题


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.


回答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.




回答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.



来源:https://stackoverflow.com/questions/31584649/how-to-remove-port-number-from-url-in-apache-tomcat-if-connector-port-is-8081

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!