I’m trying to configure 80 port and several domain names for my server.
After reading some questions and answers I edited my server.xml
file like this:
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector **port="80"** protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
**<Host name="codingrecords.tk" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Alias>www.codingrecords.tk</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context path="" docBase="/opt/tomcat/webapps/Test"
debug="0" reloadable="true"/>
</Host>**
</Engine>
</Service>
</Server>
Namely, I changed the port in <Connector> and added an extra <Host> block. However now not only can’t I access the file by IP, IP:80, IP:8080, I also can’t access it using codingrecords.tk domain name. The domain name has two A records that point to my droplet’s IP address.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
I figured it out with the help of stackoverflow. The problem was that the port was never truly changed from
8080
to80
. It happened because although I was connected as a root user to the VPS, the tomcat automatically switched to non-root usertomcat
, because of/etc/systemd/system/tomcat.service
file:So I changed a
User=tomcat
toUser=root
, restarted everything and now it works fine!