<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: NR</title>
    <description>The latest articles on DEV Community by NR (@anonycat).</description>
    <link>https://dev.to/anonycat</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3148817%2F103a1ed5-c9d4-41b9-9e18-e6e25602ef21.jpg</url>
      <title>DEV Community: NR</title>
      <link>https://dev.to/anonycat</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anonycat"/>
    <language>en</language>
    <item>
      <title>Deploy Jenkins on EC2 via Custom Domain through Nginx and SSL Secured</title>
      <dc:creator>NR</dc:creator>
      <pubDate>Mon, 18 Aug 2025 22:49:45 +0000</pubDate>
      <link>https://dev.to/anonycat/deploy-jenkins-on-ec2-via-custom-domain-through-nginx-and-ssl-secured-jm3</link>
      <guid>https://dev.to/anonycat/deploy-jenkins-on-ec2-via-custom-domain-through-nginx-and-ssl-secured-jm3</guid>
      <description>&lt;p&gt;Hello fellow reader! 👋&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;By the end you will have something like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://yourdomain.tech" rel="noopener noreferrer"&gt;https://yourdomain.tech&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;Pre-requisites:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An AWS account&lt;/li&gt;
&lt;li&gt;A domain name&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  1. Launch an EC2 Instance
&lt;/h2&gt;

&lt;p&gt;Head to the ec2 console and launch instance. Choose the configuration according to your liking for example the AMI, instance type, etc.&lt;/p&gt;

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

&lt;ol&gt;
&lt;li&gt;SSH, port 22&lt;/li&gt;
&lt;li&gt;HTTP, port 80 &lt;/li&gt;
&lt;li&gt;HTTPS, port 443&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here are some screenshots for reference:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frk15yt7qh75le8bph72c.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frk15yt7qh75le8bph72c.jpeg" alt="instance name" width="800" height="169"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fffzap0chqztj8h5avceu.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fffzap0chqztj8h5avceu.jpeg" alt="key-pair creation" width="567" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffptofoo1x7g13l0gujb1.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffptofoo1x7g13l0gujb1.jpeg" alt="security group configuration" width="800" height="736"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link:&lt;/strong&gt; &lt;a href="https://www.jenkins.io/download/" rel="noopener noreferrer"&gt;Jenkins Download Link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbfppbl1rax6w0d4uy19.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbfppbl1rax6w0d4uy19.jpeg" alt="jenkins running status" width="800" height="106"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can infer from the image, jenkins is now running on port 8080.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Configuring our domain
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Login into your account and go to dashboard&lt;/li&gt;
&lt;li&gt;Click on Domain List, find your domain and then click on manage.&lt;/li&gt;
&lt;li&gt;Click on Advanced DNS tab and add your A name host records.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4t6mmytfuq82ni7ilvym.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4t6mmytfuq82ni7ilvym.jpg" alt="Domain Host Records" width="800" height="106"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Replace the &lt;strong&gt;redacted IP with your EC2 instance's public IP&lt;/strong&gt; address. Now both yourdomain.com and &lt;a href="http://www.yourdomain.com" rel="noopener noreferrer"&gt;www.yourdomain.com&lt;/a&gt; will point to your EC2.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Installing and Configuring Nginx
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Install Nginx
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update
sudo apt install nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;Config file
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /etc/nginx/sites-available/yourdomain.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Paste the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;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;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Enable and reload Nginx
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sites-available&lt;/code&gt; 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.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sites-enabled&lt;/code&gt; 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.&lt;/p&gt;

&lt;p&gt;The second command is used to check the configuration files for any syntax errors and verify existence of configured files.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Securing our domain with SSL using Certbot
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Installing Certbot
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install certbot python3-certbot-nginx -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Generating SSL certificate
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Follow the prompts that will be given.&lt;/p&gt;




&lt;p&gt;If everything went without a hitch we will be able to see Jenkins running on our custom domain.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fum4soa4t4bdyotq40ax8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fum4soa4t4bdyotq40ax8.jpg" alt="jenkins running on custom domain" width="800" height="391"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;✨ This concludes this tutorial. Jenkins is available via our custom domain secured with SSL certificate and being reverse proxied through Nginx.&lt;/p&gt;

</description>
      <category>jenkins</category>
      <category>aws</category>
      <category>nginx</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
