Configure Jenkins reverse proxy with Nginx

Configure Jenkins reverse proxy with Nginx

1. Install NGINX on a Red Hat Enterprise Linux (RHEL).

a. First, you will need to add the official NGINX repository to your system.

You can do this by creating a new file in the /etc/yum.repos.d/ directory, for example /etc/yum.repos.d/nginx.repo, and adding the following content to it:

[nginx]

name=nginx repo

baseurl=http://nginx.org/packages/rhel/7/$basearch/

gpgcheck=0

enabled=1

b. Next, update your package list by running the command:

sudo yum update

c. Finally, install NGINX by running the command:

sudo yum install nginx

d. Once the installation is complete, you can start the NGINX service by running the command:

sudo systemctl start nginx

e. To ensure that NGINX starts automatically when the system boots, you can enable the service with the command:

sudo systemctl enable nginx

f. Finally, you can check the status of the NGINX service with the command:

sudo systemctl status nginx

Once you've finished the installation, you can verify that NGINX is working by opening a web browser and navigating to http://localhost. You should see the default NGINX welcome page.

NGINX configuration files are located in /etc/nginx. The main configuration file is nginx.conf, and the virtual host configurations are located in the conf.d directory.

2. Delete the default server details from /etc/nginx/nginx.conf

http {

    server {

        listen 80;

        server_name example.com;

         location / {

            proxy_pass localhost:8080;

        }

    }

}

3.Add jenkins.conf file in /etc/nginx/nginx.d/ folder.

a. Copy content from Reverse proxy - Nginx (jenkins.io)

b. Run these three commands.

nginx -t --> for jenkins.conf file validation

nginx -T --> check the nginx daemon loaded content

Restart nginx

systemctl restart nginx

4. Open browser and check the above-mentioned jenkins.conf server URL

http://jenkins.example.com