1

I am running EC2 instance with amazon Linux. I have installed Tomcat 9 and, by default, I am able to access the my application running on Tomcat via port 8080 and 8443.

I just wanted to switch to 80 so that I updated server.xml in the conf folder

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

and confirmed no other services running on port 80. Also,confirmed that I have enough inbound rules in the security group to listen port 80

enter image description here

Unfortunately, still not able to access via port 80.

jprism
  • 3,239
  • 3
  • 40
  • 56
  • Does this answer your question? [Tomcat Webapp on port 80](https://stackoverflow.com/questions/16326707/tomcat-webapp-on-port-80) (otherwise search for "tomcat port 80" - there are numerous questions with existing different answers here. On top, it's a configuration question, thus off topic on stackoverflow - see [help/on-topic]) – Olaf Kock Sep 12 '20 at 20:10

2 Answers2

1

I finally found at least a workaround. I used iptables to redirect in the following way.

 sudo /sbin/iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

sudo /sbin/iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443

sudo /sbin/service iptables save
sudo /etc/init.d/iptables restart

However, still not sure why do we have to do all these?

jprism
  • 3,239
  • 3
  • 40
  • 56
0

If you start tomcat using bin/startup.sh by root, it should work. There is a restriction for ports under 1000, which require process owner should be root.

If you start tomcat with sudo service tomcat start or sudo systemctl tomcat start, the owner of the process is tomcat, not root.

BYW The first process of HTTPD is root. So httpd services work.

You can find owners of processes with sudo ps -aAl.

user16217248
  • 3,119
  • 19
  • 19
  • 37