Tomcat 外部访问有问题?
我不知道如何访问我部署的战争文件,如 www.mydomain.com
相反,我必须访问它,即 http://mydomain.com:8080/WarFileName
我想解决这个问题,并且还能够在同一 Tomcat 服务器上部署/托管多个域,即 www.mydomain1.com 和 www.mydomain2.com在同一个 tomcat 服务器上,url 中没有端口 8080 变量
Server.xml 是拼图中缺失的一块吗?
信息:linux box、tomcat6、staticIP
I don't know how to access my deployed war file like this www.mydomain.com
Instead I have to access it i.e http://mydomain.com:8080/WarFileName
I would like to fix that and also be able to deploy/host more than one domain on the same Tomcat server i.e. www.mydomain1.com and www.mydomain2.com on the same tomcat server without the port 8080 variable in the url
Is Server.xml is the missing piece of the puzzle?
Info: linux box, tomcat6, staticIP
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要在 Tomcat 上设置虚拟主机。这是通过在
server.xml
中的
元素下为每个域添加单独的
条目来完成的。我上面提供的链接中有更多详细信息。You need to set up virtual hosting on Tomcat. It's done by adding a separate
<Host>
entry for each domain under the<Engine>
element inserver.xml
. More details in the link I provided above.首先,您需要确保您拥有正确的 DNS 设置,即 www.mydomain.com 和 mydomain.com 都指向相同的 IP 地址(无论您的 DNS 提供商是谁,都可以处理)。更改此设置超出了堆栈溢出的范围,如果您需要更多详细信息,可以在服务器故障上询问。
虽然您可以修改 tomcat 实例以将其提供的端口从 8080 更改为 80,并将应用程序位置从 /WarFileName 移动到 /,但这通常不是 Tomcat 的部署方式。通常 Tomcat 保留在其默认端口上,并在其前面放置一个 apache 代理来重定向来自公共域的请求,例如 http ://www.mydomain.com/ 到 http://localhost:8080/WarFileName 的内部 Tomcat 实例。
First off, you need to make sure that you have you have the proper DNS settings, i.e. that www.mydomain.com and mydomain.com both point to the same IP address (this is handled through whoever your DNS provider is). Changing this is outside the scope of stack overflow and can be asked on Server Fault if you need more details.
While you can modify the tomcat instance to change the port from 8080 to 80 it provides on and move your application location from /WarFileName to /, this is not usually how Tomcat is deployed. Usually Tomcat is left on its default port and an apache proxy is placed in front of it to redirect requests from a public domain like http://www.mydomain.com/ to the internal Tomcat instance at http://localhost:8080/WarFileName.
您需要进行以下更改,
You need to make following changes,