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.
Tomcat, in a default installation, is configured to listen on port 8080 rather than the conventional web server port number 80.
Start Tomcat on port 80 You can simply configure Tomcat to start on port 80 through modifying the “Connector” tag inside server. xml. Go to $/conf and open server. xml.
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="/" />
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With