
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:
- Launch an EC2 instance with the desired specifications.
- Connect to the instance.
- Install Jenkins using the official installation guide.[https://www.jenkins.io/doc/book/installing/]
Step2: Create an Application Load Balancer
- Navigate to the EC2 dashboard.
- Click on “Load Balancers” and then “Create Load Balancer.”
- Choose “Application Load Balancer” and configure the settings.
- Choose same VPC and security groups as ec2.
- Choose internet-facing scheme.
Step 3: Configure Target Groups:
- Create new target group for port 80, give it some name and choose same VPC as your Ec2 instance.
- 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:
- Copy Load-balancer’s DNS and access the jenkins UI.
- Follow instructions given by jenkins setup wizard.
- Setup password for admin user or create new user.
- Save settings and restart server.
- 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.