How to configure Jenkins to run on port 80 on Centos 7
How to configure Jenkins to run on port 80 on Centos 7
I've installed Jenkins, based on Jetty server on Centos 7.
In the configuration file : /etc/sysconfig/jenkins default port is 8080, and everything works perfectly, but I need to move jenkins on 80 port.
When I change JENKINS_PORT="8080" to JENKINS_PORT="80" - jenkins no longer available. Firewall I turned off.
in log messages: /var/log/jenkins/jenkins.log
Aug 17, 2017 12:07:45 PM org.eclipse.jetty.util.log.JavaUtilLog warn
WARNING: FAILED ServerConnector@4082ba93{HTTP/1.1}{0.0.0.0:80}: java.net.SocketException: Permission denied
java.net.SocketException: Permission denied
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:321)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:366)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at winstone.Launcher.<init>(Launcher.java:152)
at winstone.Launcher.main(Launcher.java:352)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at Main._main(Main.java:293)
at Main.main(Main.java:132)
Can anyone help me with that problem?
3 Answers
3
Google led me to https://confluence.atlassian.com/confkb/permission-denied-error-when-binding-a-port-290750651.html
Ports below 1024 are called Privileged Ports and in Linux (and most UNIX flavors and UNIX-like systems), they are not allowed to be opened by any non-root user.
So as I run startup script as JENKINS_USER="jenkins" the Permission denied error has appeared.
Could you try this Centos7 firewall setting?
Don't need to turn off firewall.
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload
firewall-cmd --list-all
Then starting Jenkins.
I tried that too, doesn't help.
– nimda
Aug 18 '17 at 7:23
Adding firewall entry doesn't elevate permission
– Monish Sen
Dec 22 '17 at 10:13
I struggled for hours with this problem. What i did to solve it eventually was, on Ubuntu, I changed the JENKINS_USER
variable value from $NAME to root in /etc/default/jenkins
. Then, I did a daemon reload by running the command below.
JENKINS_USER
/etc/default/jenkins
$ systemctl daemon-reload
Finally, I restarted jenkins as root.
$ service jenkins restart
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
this answer isn't complete. While you identify the problem, you've not mentioned a solution. What i did was install a httpd on port 80 and use it to proxy the tomcat
– Monish Sen
Dec 22 '17 at 10:16