如果连接器端口为 8081,如何从 apache tomcat 中的 URL 中删除端口号
how to remove port number from URL in apache tomcat if connector port is 8081
我在 linux 机器上 运行 tomcat 的多个实例。因此对于不同的实例有多个连接器端口,如 8080,8081,8082。我想从 URL 中删除端口号。
例如:-
当前 url : - www.sushant.com:8081/
需要:-www.sushant.com/
请建议我该怎么做。
谢谢。
您应该考虑在您的服务器上使用代理。 apache.org 上有一个非常好的教程,使用 Apache Web 服务器。
http://tomcat.apache.org/tomcat-7.0-doc/proxy-howto.html
这使您能够通过端口 80 连接到您的服务器,该端口未显示在浏览器的 url 栏中。
我看到上面的答案并有点挣扎,所以想举个例子,因为我在 ubuntu,所以我不得不在 /etc/apache2/
中更改 apache2.conf
文件
您可以根据 OS
找到您的 apache2.conf
文件或 httpd.conf
我添加了以下规则 -
<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>
所以,现在它可以在有和没有端口的情况下工作。
我在 linux 机器上 运行 tomcat 的多个实例。因此对于不同的实例有多个连接器端口,如 8080,8081,8082。我想从 URL 中删除端口号。
例如:-
当前 url : - www.sushant.com:8081/
需要:-www.sushant.com/
请建议我该怎么做。
谢谢。
您应该考虑在您的服务器上使用代理。 apache.org 上有一个非常好的教程,使用 Apache Web 服务器。
http://tomcat.apache.org/tomcat-7.0-doc/proxy-howto.html
这使您能够通过端口 80 连接到您的服务器,该端口未显示在浏览器的 url 栏中。
我看到上面的答案并有点挣扎,所以想举个例子,因为我在 ubuntu,所以我不得不在 /etc/apache2/
中更改 apache2.conf
文件
您可以根据 OS
apache2.conf
文件或 httpd.conf
我添加了以下规则 -
<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>
所以,现在它可以在有和没有端口的情况下工作。