How to change Jenkins' port to 80? I installed Jenkins on a Ubuntu 18.04 ec2 instance by following its official guide.

I want to change Jenkins from port 8080 (default) to port 80.

According to its official document:


  If your /etc/init.d/jenkins file fails to start Jenkins, edit the /etc/default/jenkins to replace the line ----HTTP_PORT=8080---- with ----HTTP_PORT=8081---- Here, "8081" was chosen but you can put another port available.


I managed to changed it to port 8081 but when I used port 80, it simply doesn't work:

curl -i localhost:80 returns connection refused

sudo systemctl status jenkins gives 

jenkins.service - LSB: Start Jenkins at boot time
   Loaded: loaded (/etc/init.d/jenkins; generated)
   Active: active (exited) since Thu 2019-02-21 08:14:55 UTC; 4min 12s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 6143 ExecStop=/etc/init.d/jenkins stop (code=exited, status=0/SUCCESS)
  Process: 6212 ExecStart=/etc/init.d/jenkins start (code=exited, status=0/SUCCESS)

Feb 21 08:14:53 ip-172-31-11-10 systemd[1]: Starting LSB: Start Jenkins at boot time...
Feb 21 08:14:53 ip-172-31-11-10 jenkins[6212]: Correct java version found
Feb 21 08:14:53 ip-172-31-11-10 jenkins[6212]:  * Starting Jenkins Automation Server jenkins
Feb 21 08:14:53 ip-172-31-11-10 su[6257]: Successful su for jenkins by root
Feb 21 08:14:53 ip-172-31-11-10 su[6257]: + ??? root:jenkins
Feb 21 08:14:53 ip-172-31-11-10 su[6257]: pam_unix(su:session): session opened for user jenkins by (uid=0)
Feb 21 08:14:54 ip-172-31-11-10 su[6257]: pam_unix(su:session): session closed for user jenkins
Feb 21 08:14:55 ip-172-31-11-10 jenkins[6212]:    ...done.
Feb 21 08:14:55 ip-172-31-11-10 systemd[1]: Started LSB: Start Jenkins at boot time.


I am sure nothing runs on port 80.

What am I doing wrong?
Assuming you are okay with moving your Jenkins(and settings) to a docker environment, you can do the following. This would give you the advantage to change ports(and manage jenkins) with greater ease in the future without ever having to touch IP tables or load balancers.

Host your Jenkins on a docker container and map the port 80 on your docker host daemon to 8080 on the container.

You can find the latest jenkins docker image here - https://hub.docker.com/_/jenkins 

Install docker daemon and download the image using
docker pull jenkins

You can use docker run command to start jenkins along with the -p argument to supply port values.

For instance, you are hosting your docker daemon on 10.10.169.69, then you use this to start Jenkins
docker run -t container_tag -p 80:8080 image_name

And then to browse jenkins, use http://10.10.169.69:80/