Configure Jenkins with SSL Using an Nginx Reverse Proxy¶
By default, Jenkins comes with its own built-in Winstone web server listening on port 8080, which is convenient for getting started. It’s also a good idea, however, to secure Jenkins with SSL to protect passwords and sensitive data transmitted through the web interface.
Prerequsites¶
- Jenkins installed
- An A record with
pointing to your server’s public IP address.
Update Package Repository and Upgrade Packages¶
Installing Certbot¶
The first step to using Let’s Encrypt to obtain an SSL certificate is to install the Certbot software on your server.
Run from shell prompt | |
---|---|
Confirming Nginx’s Configuration¶
Certbot needs to be able to find the correct server block in your Nginx configuration for it to be able to automatically configure SSL. Specifically, it does this by looking for a server_name directive that matches the domain you request a certificate for.
Run from shell prompt (replace domain) | |
---|---|
Obtaining an SSL Certificate¶
Certbot provides a variety of ways to obtain SSL certificates through plugins. The Nginx plugin will take care of reconfiguring Nginx and reloading the config whenever necessary. To use this plugin, type the following:
Run from shell prompt (replace domain) | |
---|---|
Select your choice then hit ENTER. The configuration will be updated, and Nginx will reload to pick up the new settings. certbot will wrap up with a message telling you the process was successful and where your certificates are stored:
Verifying Certbot Auto-Renewal¶
Let’s Encrypt’s certificates are only valid for ninety days. This is to encourage users to automate their certificate renewal process. The certbot package we installed takes care of this for us by adding a systemd timer that will run twice a day and automatically renew any certificate that’s within thirty days of expiration.
You can query the status of the timer with systemctl
:
Run from shell prompt | |
---|---|
Output should look like the below | |
---|---|
certbot
:
Run from shell prompt | |
---|---|
Nginx should now be serving your domain name. You can test this by navigating to https://your_domain