Skip to main content
All articles

Access Jenkins running on EC2 with only private IP on web

How to access Jenkins running on EC2 with only private IP on web

Sahil BansalConnect

2 min readOriginally on Medium

Introduction

Jenkins is a widely-used automation server that facilitates continuous integration and continuous delivery (CI/CD). In certain scenarios, you may need to run Jenkins on an EC2 instance with only a private IP address for security reasons. In this step-by-step guide, we’ll walk through the process of setting up Jenkins on an EC2 instance with a private IP and accessing it via a web browser.

Prerequisites:

Before diving into the tutorial, make sure you have the following:

  • An AWS account
  • A running EC2 instance with Jenkins installed
  • Basic knowledge of Jenkins

Step 1: Install Jenkins on EC2 Instance:

  1. Launch an EC2 instance with the desired specifications.
  2. Connect to the instance.
  3. Install Jenkins using the official installation guide.[https://www.jenkins.io/doc/book/installing/]

Step2: Create an Application Load Balancer

  1. Navigate to the EC2 dashboard.
  2. Click on “Load Balancers” and then “Create Load Balancer.”
  3. Choose “Application Load Balancer” and configure the settings.
  4. Choose same VPC and security groups as ec2.
  5. Choose internet-facing scheme.

Step 3: Configure Target Groups:

  1. Create new target group for port 80, give it some name and choose same VPC as your Ec2 instance.
  2. Add EC2 instance to the target group with port 8080(Jenkins) and click on ‘Include as pending below’ and create TG.

Step 4: Test Access

Verify the setup by accessing Jenkins through the ALB:

  1. Copy Load-balancer’s DNS and access the jenkins UI.
  2. Follow instructions given by jenkins setup wizard.
  3. Setup password for admin user or create new user.
  4. Save settings and restart server.
  5. Now you can see Jenkins running on browser.

Conclusion

In conclusion, we’ve successfully navigated the process of setting up Jenkins on an EC2 instance with only a private IP address, enhancing security while maintaining accessibility. Leveraging the power of an Application Load Balancer (ALB), we’ve created a seamless pathway to access Jenkins from a web browser. This approach not only fortifies our Jenkins environment but also aligns with security best practices by limiting external exposure.

  • Jenkins
  • AWS EC2
  • Networking

Written by Sahil Bansal

DevOps and platform engineer. I write about the infrastructure decisions I have had to live with.

Connect