【发布时间】:2013-12-27 06:36:59
【问题描述】:
我有一个托管在 tomcat 上的 web 应用程序。我正在尝试实现我的 webappname 的 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 request on port 80 to redirect to tomcat port 8080
我正在寻找的只是实现类似 www.myapp.com 而不是 localhost:8080/index.html 的东西。我的应用程序在端口 8080 上运行。上述配置更改后,我可以通过 www.myapp.com:8080 访问应用程序。我想从url中去掉8080。
【问题讨论】:
-
在您的 Windows 机器上是否有任何 URL 可用?如果有,有哪些?您想使用哪些 URL? Windows 应该允许您在端口 80 上启动 Apache httpd 侦听,因此不需要端口号(在主机名之后,而不是之前)。
-
我正在寻找的只是实现类似 www.myapp.com 而不是 localhost:8080/index.html 的东西。我的应用程序在端口 8080 上运行。上述配置更改后,我可以通过 www.myapp.com:8080 访问应用程序。我想从 url 中去掉 8080。
标签: apache http tomcat xampp vhosts