Table of Contents
Introduction
In this tutorial, I use Nginx reverse proxy for Jenkins in docker as the whole picture below
Procedure as below
- Host OS: Install Nginx and Docker. Using account root for setup server.
- Docker containers: Jenkins and app_devops
Installing and Configuring on CentOS/RedHat 7/6
Install Epel and Remi repository on CentOS/RedHat 6/7
### Install Epel For CentOS/RHEL 7 ###
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
### Install Epel For CentOS/RHEL 6 ###
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
### Install REMI Repository For CentOS/RHEL 7 ###
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
### Install REMI Repository For CentOS/RHEL 6 ###
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Docker install
Nginx install
# yum install nginx
start Nginx service
# service nginx start
Set up Jenkins with docker
Nginx configure
Creating Nginx configuration file directory for myapp
# mkdir /etc/nginx/conf.d/myapp/
Backup the default configuration file
# mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf_bk
Create the configuration file for myapp
# vi /etc/nginx/conf.d/server.conf
The content is below
server {
listen 80;
include /etc/nginx/default.d/*.conf;
root /usr/share/nginx/html;
#common
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Server $host:$server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
include /etc/nginx/conf.d/myapp/*.conf;
}
Nginx reverse proxy for devopsroles.com and jenkins
Configuring
Creating file devops.conf
in folder myall
# vi /etc/nginx/conf.d/myapp/devops.conf
The content is below
#for myapp
location /devopsroles/ {
proxy_pass http://localhost:68081/;
proxy_redirect http://localhost:68081/ /devopsroles/;
}
# For jenkins
location /dev_jenkins/ {
proxy_pass http://localhost:68080 ;
proxy_redirect http://localhost:68080/ /dev_jenkins/;
}
Conclusion
Through the article, You can set up “ Nginx reverse proxy for Jenkins in docker“ as above. I hope will this your helpful. Thank you for reading the DevopsRoles page!