In this tutorial, we’ll explain how to run Jenkins on port 80 in Linux. Assuming that you have already installed Jenkins or check Jenkin Installation steps for Linux.
Default Jenkins service runs on port 8080. Follow mention steps to run Jenkins on Port 80.
Steps to Run Jenkins on Port 80
There is a different method to do this, follow any one of the methods:
- Run Jenkins behind a load balancer
- Set IP table forwarding rule on Linux
- Use the reverse proxy
Method 1: Run Jenkins behind a Load Balancer
If you are on Cloud, using this method will add extra cost. Use Load balancer Service or set up your own load balancer which will forward all its traffic/requests from 80 to Jenkins 8080 port (backend).
Method 2: Set IP table forwarding rule on Linux
This is the simple method to access our application(Jenkins) on port 80 follow mention steps.
$ sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
Save IP table forwarding rule – If you forget to save the rule then after reboot you need to set IP table forwarding once again.
For RHEL Operating System:
$ sudo iptables-save > /etc/sysconfig/iptables (Or) $ service iptables save
For Debian System
$ sudo sh -c "iptables-save > /etc/iptables.rules"
Now access Jenkins with port 80 on your web browser, the IP table automatically forwards all traffic to port 8080.
Make sure iptables service must be running all the time.
# service iptables start
Auto start iptables on reboot
# chkconfig iptables on
Method 3: Use the reverse proxy
In this article, we will take the example of Nginx where Jenkins will be a backend box.
Assuming that you have already install Nginx on Linux if not check Nginx installation steps.
After you have installed Nginx then configure Nginx.
$ sudo vi /etc/nginx/nginx.conf #Goto the mention line location / { } Now add the following lines proxy_pass http://127.0.0.1:8080; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme;
Now, stop SELinux as you are testing it.
# setenforce 0 setenforce: SELinux is disabled
Next step, to restart Nginx service on Linux
$ sudo service nginx restart Or $ sudo systemctl restart nginx
This is the tutorial, how to run Jenkins on Port 80 in Linux with 3 methods.
References for RHEL / CentOS 4/5/6
Linux Command to Disable firewall
# service iptables save # service iptables stop # chkconfig iptables off
Linux Command to Enable firewall
# service iptables start # chkconfig iptables on
Verify that firewall
# /sbin/iptables -L -v -n OR # service iptables status
This is the end of the tutorial, How to run Jenkins on Port 80 in Linux.