0
votes

I have recently bought Amazon EC2 server. Instead of installing it trough command line, I downloaded the latest zip file and deployed my application in WebApps folder.

The problem is tomcat is listening all the requests on port 8080 instead of 80. I have tried changing the server.xml file in conf folder but no help!! It is still listening to port 8080.

How do I make it listen to port 80

4
Is googling so hard? mkyong.com/tomcat/how-to-change-tomcat-default-portuser2889419
Well example in article is setting to port 8181 not 80. I want to make tomcat listen to port 80. You can set port number in server.xml greater than 1024. that is not what i want. Plus setting it port 8181 did not work either.Fahad Mullaji

4 Answers

2
votes

Oddly enough, Tomcat has its own documentation about doing this:

http://wiki.apache.org/tomcat/HowTo#How_to_run_Tomcat_without_root_privileges.3F

Probably the most straightforward way on *NIX is to use jsvc which is a small utility that works by binding to a port, dropping privileges, and then launching Tomcat, which can then use lower-numbered ports.

There are a bunch of other ways, but jsvc is the easiest and offers some other benefits as well. Discovering those benefits is left as an exercise for the reader.

1
votes

The following would apply toward various systems, while the second link would related toward windows based systems.

First link :http://www.klawitter.de/tomcat80.html

Second link: http://javarevisited.blogspot.com/2011/12/how-to-change-tomcat-default-port-8080.html?m=1

0
votes

Ok. So finally I figured out way to solve this problem.

First of all i was doing it wrong way. One should not open port 80 for tomcat7. Tomcat7 should always run port 8080 or anything which is greater than 1024.

So to make your web site work without port. Follow below steps.

  1. Install Apache2. (By default it runs on port 80).
  2. Go to localhost and make sure apache2 is installed properly.
  3. Then you will have to redirect all the requests which are going on port to redirect to port 8080.
  4. To do that follow below link. (this is important step) https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension

Hope this answer helps!!!

Thanks Fahad Mullaji

0
votes

I wouldn't recommend doing that, for what it is worth...

That could work in theory, but you are literally using httpd as a proxy to forward every request. There isn't much of a reason, IMHO, to choose this over simply changing the port to 80 in the Tomcat configuration and ditching httpd. You can use port 80 for Tomcat but historically, in production environments, httpd is generally used to serve static assets and such and dynamic content would be served by Tomcat. Generally one would install mod_jk and use the jkMount directive to connect Tomcat to httpd via AJP, which is a lot faster being a binary protocol than using HTTP.

There used to be a much bigger difference in terms of performance, here.

Tomcat is able to serve static resources via its DefaultServlet pretty well these days.

For AJP setup, see the documentation here:

https://tomcat.apache.org/tomcat-4.0-doc/config/ajp.html