Deploy Jenkins on EC2 via Custom Domain through Nginx and SSL Secured

Hello fellow reader! đź‘‹

In this tutorial we will be going through on how to deploy Jenkins on AWS EC2 instance via a custom domain through Nginx as a reverse proxy and how to secure it using ssl.

By the end you will have something like:

https://you…


This content originally appeared on DEV Community and was authored by NR

Hello fellow reader! đź‘‹

In this tutorial we will be going through on how to deploy Jenkins on AWS EC2 instance via a custom domain through Nginx as a reverse proxy and how to secure it using ssl.

By the end you will have something like:

https://yourdomain.tech

Pre-requisites:

  • An AWS account
  • A domain name
  • Linux terminal knowledge

1. Launch an EC2 Instance

Head to the ec2 console and launch instance. Choose the configuration according to your liking for example the AMI, instance type, etc.

Make sure you have a key-pair (will be used later) and a security group configured to allow traffic from ports:

  1. SSH, port 22
  2. HTTP, port 80
  3. HTTPS, port 443

Here are some screenshots for reference:

instance name

key-pair creation

security group configuration

Go to your terminal and connect to your instance via ssh or you can connect to it through the console. To install Jenkins we need to first install its dependency i.e java. You can follow the official documentation from Jenkins site to install Jenkins as per your operating system. Don't forget to start and enable it.

Link: Jenkins Download Link

jenkins running status

As we can infer from the image, jenkins is now running on port 8080.

2. Configuring our domain

Go to the site from where you purchased your domain from. We will be using Namecheap for this tutorial as that is where I purchased my domain from.

  1. Login into your account and go to dashboard
  2. Click on Domain List, find your domain and then click on manage.
  3. Click on Advanced DNS tab and add your A name host records.

Domain Host Records

Replace the redacted IP with your EC2 instance's public IP address. Now both yourdomain.com and www.yourdomain.com will point to your EC2.

3. Installing and Configuring Nginx

  • Install Nginx
sudo apt update
sudo apt install nginx

By default, Jenkins runs on port 8080 which means we'd have to go to http://<ec2-ip>:8080 to use Jenkins. Through configuring Nginx as a reverse proxy we can simply go to https://your-domain.com and Nginx will forward our request to Jenkins running on our EC2 IP.

  • Config file
sudo nano /etc/nginx/sites-available/yourdomain.com

Paste the following:

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;

    location / {
        proxy_pass http://localhost:8080;   
        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;
    }
}
  • Enable and reload Nginx
sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

The first command creates a symbolic link which is a common method for managing website configurations, particularly within sites-available and sites-enabled directory structure.

sites-available directory typically stores all our individual website configuration files (e.g., example.com.conf, blog.conf). These files contain the Nginx server block configurations for each site.

sites-enabled directory contains symbolic links pointing to the configuration files in sites-available that we wish to enable. Nginx is configured to include the files within sites-enabled when it loads its configuration, effectively activating the linked site configurations.

The second command is used to check the configuration files for any syntax errors and verify existence of configured files.

4. Securing our domain with SSL using Certbot

  • Installing Certbot
sudo apt install certbot python3-certbot-nginx -y
  • Generating SSL certificate
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

Follow the prompts that will be given.

If everything went without a hitch we will be able to see Jenkins running on our custom domain.

jenkins running on custom domain

✨ This concludes this tutorial. Jenkins is available via our custom domain secured with SSL certificate and being reverse proxied through Nginx.


This content originally appeared on DEV Community and was authored by NR


Print Share Comment Cite Upload Translate Updates
APA

NR | Sciencx (2025-08-18T22:49:45+00:00) Deploy Jenkins on EC2 via Custom Domain through Nginx and SSL Secured. Retrieved from https://www.scien.cx/2025/08/18/deploy-jenkins-on-ec2-via-custom-domain-through-nginx-and-ssl-secured/

MLA
" » Deploy Jenkins on EC2 via Custom Domain through Nginx and SSL Secured." NR | Sciencx - Monday August 18, 2025, https://www.scien.cx/2025/08/18/deploy-jenkins-on-ec2-via-custom-domain-through-nginx-and-ssl-secured/
HARVARD
NR | Sciencx Monday August 18, 2025 » Deploy Jenkins on EC2 via Custom Domain through Nginx and SSL Secured., viewed ,<https://www.scien.cx/2025/08/18/deploy-jenkins-on-ec2-via-custom-domain-through-nginx-and-ssl-secured/>
VANCOUVER
NR | Sciencx - » Deploy Jenkins on EC2 via Custom Domain through Nginx and SSL Secured. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/08/18/deploy-jenkins-on-ec2-via-custom-domain-through-nginx-and-ssl-secured/
CHICAGO
" » Deploy Jenkins on EC2 via Custom Domain through Nginx and SSL Secured." NR | Sciencx - Accessed . https://www.scien.cx/2025/08/18/deploy-jenkins-on-ec2-via-custom-domain-through-nginx-and-ssl-secured/
IEEE
" » Deploy Jenkins on EC2 via Custom Domain through Nginx and SSL Secured." NR | Sciencx [Online]. Available: https://www.scien.cx/2025/08/18/deploy-jenkins-on-ec2-via-custom-domain-through-nginx-and-ssl-secured/. [Accessed: ]
rf:citation
» Deploy Jenkins on EC2 via Custom Domain through Nginx and SSL Secured | NR | Sciencx | https://www.scien.cx/2025/08/18/deploy-jenkins-on-ec2-via-custom-domain-through-nginx-and-ssl-secured/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.