Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
No Result
View All Result
Home Google Cloud

How to Setup Jenkins with SSL with Apache Reverse Proxy on Ubuntu 18.04

by Cloudbooklet
4 years ago
in Google Cloud, Compute Engine
How To Setup Jenkins With Ssl With Apache Reverse Proxy On Ubuntu 18.04
ShareTweetSendShare
Readers like you help support Cloudbooklet. When you make a purchase using links on our site, we may earn an affiliate commission.

How to Setup Jenkins with SSL with Apache Reverse Proxy on Ubuntu 18.04. By default Jenkins listens on port 8080 with it’s in-built web server. But it is necessary to secure Jenkins with SSL for protecting the sensitive data. In this tutorial you are going to learn how to setup Apache as a reverse proxy […]

ADVERTISEMENT

How to Setup Jenkins with SSL with Apache Reverse Proxy on Ubuntu 18.04. By default Jenkins listens on port 8080 with it’s in-built web server. But it is necessary to secure Jenkins with SSL for protecting the sensitive data.

In this tutorial you are going to learn how to setup Apache as a reverse proxy to Jenkins on Ubuntu 18.04 on Google Cloud.

This setup is tested on Google Cloud and it will pretty run the same on any Linux distributions.

ADVERTISEMENT

Prerequisites

  • A running Compute Engine, see the Setting up Compute Engine Instance with Ubuntu 18.04
  • Initial Ubuntu Server Set up.
  • Jenkins installed with the steps listed on How to install Jenkins on Ubuntu 18.04
  • DNS setup with the steps listed in Setting up Google Cloud DNS for your domain

Install Apache

Install Apache with the following command.

You might also like

How To Setup Ssh Keys On Ubuntu

How to Setup SSH Keys on Ubuntu 20.04

4 months ago
Draggan Ai Editing Tool Install And Use Draggan Photo Editor

DragGAN AI Editing Tool Install and Use DragGAN Photo Editor

4 months ago
sudo apt install apache2

This command will install Apache on your VM instance.

Setup Firewall

Once Apache is installed you can configure firewall, Apache registers itself with ufw. So, you can allow the necessary ports and enable ufw.

ADVERTISEMENT
sudo ufw allow OpenSSH
sudo ufw allow 'Apache Full'

Make sure you have added rules for SSH port 22, if you haven’t done this you cannot access the SSH. Once you have verified you can enable UFW.

sudo ufw enable

Configure Apache for Jenkins

Enable Apache modules.

ADVERTISEMENT
a2enmod proxy
a2enmod proxy_http
a2enmod headers

Now it’s time to configure Apache as a reverse proxy for Jenkins.

Remove the default Apache configuration.

ADVERTISEMENT
sudo a2dissite 000-default

Create a new configuration for Jenkins.

sudo nano /etc/apache2/sites-available/jenkins.conf

Configuration for Jenkins on Subdomain

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName jenkins.yourdomainname.com
    ServerAlias jenkins.yourdomainnamecom

    <Proxy http://127.0.0.1:8080/>
      Order deny,allow
      Allow from all
    </Proxy>

    ProxyPass         /  http://127.0.0.1:8080/ nocanon
    ProxyPassReverse  /  http://127.0.0.1:8080/
    ProxyPassReverse  /  http://jenkins.yourdomainname.com/

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Paste this new configuration setting and hit Ctrl+X followed by Y to save the file.

ADVERTISEMENT

Configuration for Jenkins on Sub-directory

Paste this new configuration setting and hit Ctrl+X followed by Y to save the file.

<Virtualhost *:80>
    ServerName        yourdomainname.com

    ProxyRequests     Off
    ProxyPreserveHost On
    AllowEncodedSlashes NoDecode

    <Proxy http://127.0.0.1:8080/jenkins*>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPass         /jenkins  http://127.0.0.1:8080/jenkins nocanon
    ProxyPassReverse  /jenkins  http://127.0.0.1:8080/jenkins
    ProxyPassReverse  /jenkins  http://35.244.93.246/jenkins
</Virtualhost>

Hit Ctrl + X followed by Y and Enter to save and exit the file.

Enable the configuration.

sudo a2ensite jenkins.conf

Configure Jenkins for Apache

In order to Jenkins work with Apache you need to make Jenkins to listen on localhost

sudo nano /etc/default/jenkins

Find the JENKINS_ARGS line and add --httpListenAddress=127.0.0.1 to the existing arguments.

So, the line will look similar to the one below.

JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT --httpListenAddress=127.0.0.1"

For sub-directory configuration you need to add additional argument with the directory name with --prefix

JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT --httpListenAddress=127.0.0.1 --prefix=/jenkins"

Save and exit the file. Finally restart Jenkins.

sudo systemctl restart jenkins

Check the configuration and restart Apache.

sudo apachectl configtest
sudo service apache2 restart

Now Apache is setup as a reverse proxy for Jenkins.

Install Free Let’s Encrypt SSL Certificate

sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt install python-certbot-apache
sudo certbot --apache -m your-email -d yourdomainname.com -d www.yourdomainname.com

That’s all now you can visit your domain name in your web browser. You can see your Jenkins login page with HTTPS.

Conclusion

In this tutorial you have installed Apache, configured UFW, setup new reverse proxy configuration for Jenkins and installed SSL and configured Jenkins for Apache.

Tags: Compute EngineGoogle Cloud PlatformJenkins
Share2Tweet1SendShare
Cloudbooklet

Cloudbooklet

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Related Posts

Set Up Deep Learning With Nvidia, Cuda, Cudnn On Ubuntu

How to Set Up Deep Learning with Nvidia, CUDA, cuDNN on Ubuntu 22.04

7 months ago
How To Install Or Upgrade Php 8.2 On Ubuntu 22.04

How to Install or Upgrade PHP 8.2 on Ubuntu 22.04

9 months ago
How To Change Timezone On Ubuntu 22.04

How to Change Timezone on Ubuntu 22.04

1 year ago
How To Install Ansible On Ubuntu 22.04

How to Install Ansible on Ubuntu 22.04

1 year ago

Follow Us

Trending Articles

Ai Annotation Jobs

AI Annotation Jobs: Everything You Need to Know

September 18, 2023

10 Best AI Song Generator in 2023 (Free and Paid)

Validator AI: The AI Powered Business Idea Validator

How to Use ChatGPT to Translate Your Website or Blog

Google Bard Extensions: How to Link Your Gmail, Docs, Maps, and More to an AI Chatbot

Microsoft Surface Event: The Most Exciting and Innovative Launches and Updates

Popular Articles

Personal Ai Assistant With Localgpt

How to Create a Personal AI Assistant with LocalGPT

September 12, 2023

10 Best AI Copywriting Tools That Will Boost Your Content Marketing

Charley AI: The Best AI Essay Writing Tool

ImgCreator AI: Free AI Image Generator by ZMO

How to Use Adobe AI Audio Enhancer to Fix and Edit Your Recordings

How to Easily Remove Background in Microsoft Paint and Paint 3D

Subscribe Now

loader

Subscribe to our mailing list to receives daily updates!

Email Address*

Name

Cloudbooklet Logo

Welcome to our technology blog, where we explore the latest advancements in the field of artificial intelligence (AI) and how they are revolutionizing cloud computing. In this blog, we dive into the powerful capabilities of cloud platforms like Google Cloud Platform (GCP), Amazon Web Services (AWS), and Microsoft Azure, and how they are accelerating the adoption and deployment of AI solutions across various industries. Join us on this exciting journey as we explore the endless possibilities of AI and cloud computing.

  • About
  • Contact
  • Disclaimer
  • Privacy Policy

Cloudbooklet © 2023 All rights reserved.

No Result
View All Result
  • News
  • Artificial Intelligence
  • Applications
  • Linux

Cloudbooklet © 2023 All rights reserved.