Tomcat Webapp on port 80 [duplicate]

亡梦爱人 提交于 2019-11-29 12:50:20

问题


I have a webapp on my tomcat server like this:

mydomain.com:8080/mywebapp

Then I connect to my webapp, and it is working correctly, but what I want is to see my webapp like this:

mydomain.com

So I don't want only tomcat on port 80, I don't want to access my webapp through its name, I want to connect directly using my domain URI.

How can I do this? I want this to work with Linux (Ubuntu 12.04 LTS) and Windows servers.


回答1:


There are several ways to achieve this, but the most common way to solve it is to run Apache as a reverse proxy in front of it. You can find some details here. This will work on both Linux and Windows. For Linux, you can also use authbind to allow Tomcat to bind to port 80. Just changing the port to 80 in your server.xml will not work in Linux, since it would require you to start Tomcat as root, which is not a very good idea.

Also, to have your webapp at /, you can deploy your war file as ROOT.war.




回答2:


Running any application on a privileged port (those below 1024) requires special privileges. If you do this, you should ensure your instance is properly hardened.

To configure the port tomcat listens on you have to modify the HTTP connector in conf/server.xml (server reference documentation):

<Connector port="80" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />

To change the context path of an app, you can rename the war file. To deploy it at the root, rename your war file to ROOT.war. Or you can add a META-INF/context.xml in which you can specify the desired context path (context reference docs):

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/" />



回答3:


You need to set apache webserver and configure it to use tomcat.

You need to use mod_jk in order to configure apache webserver to communicate with tomcat.

Use this link to set up the mod_jk.



来源:https://stackoverflow.com/questions/16326707/tomcat-webapp-on-port-80

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