How to configure Jenkins to run on port 80
- Go to /etc/default folder --> Open the file "jenkins"
- Modify the line HTTP_PORT=8080 as HTTP_PORT=80
- Start jenkins as root by using the command: sudo /etc/init.d/jenkins start
- Open a browser and browse as localhost:80
that's it
Give a try to 'authbind':
sudo apt-get install authbind
sudo touch /etc/authbind/byport/80
sudo chmod 500 /etc/authbind/byport/80
sudo chown jenkins /etc/authbind/byport/80
Then modify the script above to have (add authbind
before the $JAVA_HOME/bin/java
part):
exec daemon --name=jenkins --inherit --output=$JENKINS_LOG/jenkins.log \
--user=$USER -- authbind $JAVA_HOME/bin/java $JAVA_OPTS \
-jar $JENKINS_ROOT/jenkins.war $JENKINS_ARGS \
--preferredClassLoader=java.net.URLClassLoader
For newer Jenkins installations (1.598) on newer Ubuntu installations (14.04) edit /etc/init.d/jenkins
and add authbind
before $JAVA
$SU -l $JENKINS_USER --shell=/bin/bash -c "$DAEMON $DAEMON_ARGS -- authbind $JAVA $JAVA_ARGS -jar $JENKINS_WAR $JENKINS_ARGS" || return 2
As mentioned by Alan (see comment below) if you need IPv6 and your system is lower than Quantal you can instead of using apt-get
to install authbind
download a higher version.
Make sure you have libc6
and libc6-udeb
installed. Here is authbind
version 2.1.1 from Ubuntu:
- amd64
- i386
Then execute:
sudo dpkg -i authbind_2.1.1_amd64.deb
# or sudo dpkg -i authbind_2.1.1_i386.deb
sudo touch /etc/authbind/byport/80
sudo chmod 500 /etc/authbind/byport/80
sudo chown jenkins /etc/authbind/byport/80
Another solution is to simply use iptables to reroute incoming traffic from 80 to 8080. The rules would look like:
-A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
-A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT
-A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
Reformatted as an iptables.rules file:
*filter
:INPUT ACCEPT [100:100000]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [95:9000]
-A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
-A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT
COMMIT
*nat
-A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
COMMIT
The advantage of a iptable.rules file is the rules can persist after reboots. Just make sure to integrate any other current iptable rules into the same file!
On Redhat/CentOS this file can go in /etc/sysconfig/iptables
.
On Debian/Ubuntu systems they can be saved in /etc/iptables/rules.v4
by using the iptables-persistent
package. Or the iptable.rules can be called by modifying /etc/network/interfaces
or hooking into if-up
/if-down
scripts. The Ubuntu Community wiki has a great page explaining these methods.
As is usually the case with networking, there's a lot of different ways to accomplish the same result. Use what works best for you!