Link to home
Start Free TrialLog in
Avatar of Williams225
Williams225

asked on

How to change tomcat port from 8080 to 80 under Centos7

Hi All,

I have installed Tomcat under Centos7
EVerything is working but when I change connector port from 8080 to 80  (/opt/tomcat/conf/server.xml) Im not able to access the site anymore.
What other configuration do I have to make for my site to work on port 80
server.xml
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Are you certain that you don't already have a web server running on 80?
Avatar of dpearson
dpearson

A couple of other potential problems beyond another service running on 80:
 - You may have a firewall blocking port 80
- The user you are using to run tomcat may not have permission to open a port under 1024 (root has this permission, I believe on CentOS other users do not and need to sudo over when opening the port).  See this discussion: http://www.debian-administration.org/article/386/Running_network_services_as_a_non-root_user.

To see if tomcat had an error when it tried to open the port, check the catalina.out log file under tomcat/logs.

To see if the service is indeed running successfully on port 80 you can use the commands here:
https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s1-server-ports.html

If the tomcat server is indeed shown as listening on port 80, but you still can't connect then it's likely a firewall problem.

You can confirm a firewall issue by trying to telnet to the port
    telnet yourserver.com 80
from another box - which will fail with "access denied" or some such if a firewall is blocking it.

Hope some of that helps,

Doug
Avatar of Williams225

ASKER

Hi all,

its a fresh installation and tomcat its the only web server running
@Doug I think the problem is a permission problem

17-Apr-2016 23:03:05.812 SEVERE [main] org.apache.coyote.AbstractProtocol.init Failed to initialize end point associated with ProtocolHandler ["http-nio-80"]
 java.net.SocketException: Permission denied

Open in new window

Depending on why, you could add workers on Apache to access the tomcat apps data.
Tomcat has a larger overhead for serving static data/images.

Have not looked, but the port is set within the catelina.conf file.
ASKER CERTIFIED SOLUTION
Avatar of dpearson
dpearson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The best configurations of servers running on port 80 don't run as root. e.g. Apache on Debian starts as root but then forks to user www-data. You could run Tomcat with Apache to solve the problem. That way you'd also have the benefit of having Apache serve static pages which would be more efficient than Tomcat
Hi,

I have started tomcat as root and that has fixed the permission problem.
But I dont want to run my server that way.

I have created a user call tomcat which does not have root privilege and that user normaly run the service. But of course now I understant that its not allow to bind the 80 port.

So what should I do
Well, i think i already told you ;)
Look at using apache on port 80 with workers querying  tomcat for the data That is the general setup.
Tomcat is a java based app meaning if it is not running as root, by the time it starts the java component which is the one that binds to port 80 .....
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Not a good idea, btw, to have Tomcat running as root, which is why web servers don't run as root (when they're properly configured) as described HERE
authbind-centos-rpm worked well and was quick to setup. You can pull a pre-built RPM from this page. https://aaronsilber.me/2016/04/24/install-authbind-on-centos-7-x86_64-download-the-rpm/