We help IT Professionals succeed at work.

Check out this week's podcast, "Dairy Farms to Databases: Community's Hand in Technology"Listen Now

x

How to change tomcat port from 8080 to 80 under Centos7

Williams225
Williams225 asked
on
8,991 Views
Last Modified: 2016-08-19
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
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016

Commented:
Are you certain that you don't already have a web server running on 80?
CERTIFIED EXPERT

Commented:
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
Williams225System Administator

Author

Commented:
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

CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
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.
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2016

Commented:
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
Williams225System Administator

Author

Commented:
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
CERTIFIED EXPERT
Top Expert 2016

Commented:
Well, i think i already told you ;)
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
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 .....
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2016

Commented:
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
Anton ResnickManager

Commented:
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/

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.