Nginx reverse proxy for Jenkins in docker

In this tutorial, I use Nginx reverse proxy for Jenkins in docker as the whole picture below

Nginx reverse proxy for Jenkins in docker

Procedure as below

Host OS: Install Nginx and Docker. Using account root for setup server.

Docker containers: Jenkins and app_devops

Installing and Configuring Packages 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 configuration file for myapp

# vi /etc/nginx/conf.d/server.conf

The content as 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 as 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

Thought the article, You can setup “ Nginx reverse proxy for Jenkins in docker as above. I hope will this your helpful.

, ,

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

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

Comment moderation is enabled. Your comment may take some time to appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.