This tutorial will help you hide your jenkins http page behind VPN
- Edit jenkins config /etc/default/jenkins:
- Change:
HTTP_PORT=8080
to
HTTP_PORT=8081 HTTP_HOST=127.0.0.1
- Change:
JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT"
to:
JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT --httpListenAddress=$HTTP_HOST"
- Restart jenkins:
service jenkins restart
- Install nginx:
apt install nginx-light
- Create config file /etc/nginx/sites-available/jenkins:
upstream app_server { server 127.0.0.1:8081 fail_timeout=0; } server { listen 8080; listen [::]:8080 default ipv6only=on; server_name <domain>; location / { # allow VPNs allow <whitelisted ip>; allow <another whitelisted ip>; # drop rest of the world deny all; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://app_server; break; } } }
- Enable config:
ln -s /etc/nginx/sites-available/jenkins /etc/nginx/sites-enabled/jenkins
- Restart nginx:
service nginx restart
- #Profit
If you have any questions regarding this - ask Kamil
Back to top