Jenkins-Tomcat-Sonar-Nexus Nginx Reverse Proxy and SSL Setup
Jenkins-Tomcat-Sonar-Nexus Nginx Reverse Proxy and SSL Setup
Note:
Setting up SSL for the Jenkins server directly using its IP address is not possible. To
enable SSL, it's nessesary to have a domain name associated with the Jenkins server.
Without a domain name, obtaining an SSL certificate is challenging, as it typically
requires proof of ownership for the associated IP address.
Unfortunately, in this case, we cannot provide ownership proof for the EC2 instance's IP
address because we don't have access to control or manage the ownership of the ec2 IP
address
In my case, I have already purchased a domain name from one.com, and we can configure
it to point to your Jenkins server. This allows you to access your Jenkins server using your
existing domain name.
• After Nginx is installed, you'll need to configure it to act as a reverse proxy for your
Jenkins server. This configuration process typically involves creating an Nginx server
block (also known as a virtual host) to direct incoming traffic to the Jenkins server.
• In Vi command mode, enable line numbers and comment out lines 38 to 54 in the
nginx.conf file
:set numbers
:38,54s/^/#
• After making the necessary changes, save the nginx.conf file and exit the Vi editor
server {
listen 80;
server_name awsdevops.nl;
location / {
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://jenkins;
# Required for new HTTP-based CLI
proxy_http_version 1.1;
proxy_request_buffering off;
proxy_buffering off; # Required for HTTP-based CLI to work over SSL
}
}
Step 6: Creating an SSL Certificate for Your Domain using certbot application
• To create an SSL certificate for your domain, you can use the Certbot package
Install Certbot and the Certbot Nginx plugin by running the following command:
sudo apt install certbot python3-certbot-nginx
• This will automatically update the Nginx configuration to include SSL settings and
redirect HTTP traffic to HTTPS
Step 8: Access Jenkins Web Interface
• Access Jenkins web interface on https://awsdevops.nl
------------------------------------------------------------------------------------------------------
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
server {
listen 80;
server_name tomcat.awsdevops.nl;
location / {
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://tomcat;
# Required for new HTTP-based CLI
proxy_http_version 1.1;
proxy_request_buffering off;
proxy_buffering off; # Required for HTTP-based CLI to work over SSL
}
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Prevent "The plain HTTP request was sent to HTTPS port" error
proxy_redirect http:// https://;