DEV Community 👩‍💻👨‍💻

Harrsh Patel
Harrsh Patel

Posted on

Secure Jenkins with Nginx

Part 1 - Configure Nginx for Jenkins

  • Add a new A record for Jenkins with the ipv4 address of the server.

  • Add a new server block below the existing server blocks.

  • Sample server block looks like,

server {
    server_name <domain-name for Jenkins>;

    location / {
        proxy_pass http://localhost:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
    listen 80;
}
Enter fullscreen mode Exit fullscreen mode
  • Check nginx config via,
sudo nginx -t
Enter fullscreen mode Exit fullscreen mode
  • Restart nginx via,
sudo service nginx restart
Enter fullscreen mode Exit fullscreen mode
  • Check if everything worked fine by going to the URL in the browser. It should open the Jenkins UI.

Part 2 - Configure SSL for Jenkins


Part 3 - Configure Nginx for Jenkins

sudo nano /etc/nginx/sites-available/default
Enter fullscreen mode Exit fullscreen mode
  • Edit file for Jenkins server block.
server {
    # SSL Configuration
    access_log /var/log/nginx/jenkins.access.log;
    error_log /var/log/nginx/jenkins.error.log;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Classic DEV Post

brain computer interface

Experimenting with brain-computer interfaces in JavaScript