Prevent Jenkins access on port 8080
You can use iptables since it's Ubuntu, to block all non-local access to port 8080.
iptables -A INPUT -p tcp --dport 8080 -s localhost -j ACCEPTiptables -A INPUT -p tcp --dport 8080 -j DROP
There is another solution (without the need for IPtables):
Prevent jenkins from being accessed outside of the server in port 8080:
- Edit file /etc/default/jenkins
- Add
HTTP_HOST=127.0.0.1
In the end change the line:
- From:
JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT"
- To:
JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT --httpListenAddress=$HTTP_HOST"
- From:
Restart the jenkins
systemctl restart jenkins