0
votes

I followed following steps to run my web application

  1. I have created an ec2 instance of ubuntu 16.04 LTS on aws.
  2. Using remote login by ssh, I installed java 8, and then tomcat: sudo apt-get install tomcat7. (tomcat9 could not install using same command)
  3. I renamed my war file to ROOT(because project name should not be in URL) and copied it to webapps folder.
  4. After starting tomcat, using http://IP_address:8080 I can access my website. default setting in server.xml: connector port=”8080” ... I checked which services are running netstat –plnt 8005(server shutdown port), 8080(connector port)
  5. I changes port number from server.xml to 80: connector port=”80” .. Then started tomcat. I could not access my website. also following command doesn't show any service running on port 80.
    netstat –plnt 8005(server shutdown port)

What changes need to be made so that website will be accessible without entering any port number in URL. (I already mapped domain name to IP address.) I want to use java 8 features hence I prefer tomcat 9 installation.

2
You should probably google that problem. There's plenty of tutorials on how to run tomcat on port 80 specifically on EC2. Also, if you wish to use Tomcat 9, just download it, unpack and then run it through ./startup.shCargeh
I already googled it. After configuring tomcat to run on port 80 by making change in server.xml. No service is running on it. What other configuration changes needed?user2976975

2 Answers

9
votes

A simple solution (tested on EC2 running on ubuntu). Basically redirects all traffic from port 80 to 8080.

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

People also suggest installing iptables-persistent (through apt-get install) to save the changes, but I personally haven't tested it out.

Make sure you allow port 80 in your AWS console. To do that, under Network & Security go to Security groups, choose the group of your EC2 instance, select it and go to Inbound (at the bottom), then edit, and Add Rule with port 80. You might have to wait for some time.

-2
votes

Yes, This worked perfectly.

The otherway is create a subdomain if you have domain like abc.techuva.com and map it to your url:8080 etc and make it work.

  • Shan