我有一个托管在Tomcat上的Web应用程序。我正在尝试实现对我的Web应用程序名称的URL重定向。因此,我正在使用我的XAMPP安装中Apache的vhosts配置。
我使用的工具:Tomcat,XAMPP,APACHE
我所做的更改:
In /System32/drivers/etc/hosts
127.0.0.1 www.myapp.com
此外,我请求获得了一个域名。
nslookup myapp.com
Server: xxx.xx.xxx.xxx
Address: xxx.xx.xxx.xxx#53
myapp.com canonical name = blah-blah-myapp.com.
Name: myapp.com
Address: xxx.xx.xxx.xxx
在Tomcat的server.xml文件中:
<Connector className="org.apache.catalina.connector.http.HttpConnector"
connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"
proxyName="www.myapp.com"
proxyPort="80"/>
在httpd.conf文件中:
LoadModule proxy_module modules/mod_proxy.so
#AddModule mod_proxy.c # Gave error when tried to follow the docs
ProxyPass /MyAppPath http://localhost:8080/MyAppPath
ProxyPassReverse /MyAppPath http://localhost:8080/MyAppPath
在 http-vhosts.conf 文件中:
<VirtualHost *:80>
ServerName myapp.com
ServerAlias www.myapp.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /MyAppPath http://localhost:8080
ProxyPassReverse http://localhost:8080
通过进行这些配置,我在我的Macintosh机器上实现了功能。但是,在Windows服务器上出现了问题。我在Windows安装配置文件中进行了相同的更改,但它没有跳过端口号。我的应用程序只能在域名前面加上端口号才能运行。我该如何使
http请求在80端口重定向到tomcat 8080端口
?我想要实现的只是像www.myapp.com这样的东西,而不是localhost:8080/index.html。我的应用程序运行在8080端口上。在进行上述配置更改后,我能够通过www.myapp.com:8080访问应用程序。我想要消除url中的8080。