<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nosa Shandy</title>
    <description>The latest articles on DEV Community by Nosa Shandy (@nosashandy).</description>
    <link>https://dev.to/nosashandy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F463186%2Fa83e7f4a-68a6-4566-be7d-e81eb64e0a84.jpeg</url>
      <title>DEV Community: Nosa Shandy</title>
      <link>https://dev.to/nosashandy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nosashandy"/>
    <language>en</language>
    <item>
      <title>Setup Jenkins and Gitlab on Custom Subdomain with Nginx Proxy Manager</title>
      <dc:creator>Nosa Shandy</dc:creator>
      <pubDate>Mon, 26 Dec 2022 08:08:01 +0000</pubDate>
      <link>https://dev.to/nosashandy/setup-jenkins-and-gitlab-on-custom-subdomain-with-nginx-proxy-manager-1mhh</link>
      <guid>https://dev.to/nosashandy/setup-jenkins-and-gitlab-on-custom-subdomain-with-nginx-proxy-manager-1mhh</guid>
      <description>&lt;h2&gt;
  
  
  📍 Description
&lt;/h2&gt;

&lt;p&gt;The goal on this tutorial to make the small labs that the Jenkins, and Gitlab can run on the VPS and also we can access them with custom subdomain like: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;jenkins.domain.com&lt;/li&gt;
&lt;li&gt;gitlab.domain.com&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BeGuLsdL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p6wm7a0nhhsv5gys1y1s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BeGuLsdL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p6wm7a0nhhsv5gys1y1s.png" alt="Nginx Proxy Manager" width="880" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To make this possible, we need help &lt;strong&gt;Nginx Proxy Manager&lt;/strong&gt; to create proxy to our specific IP Address and port. We will install the jenkins, and gitlab on the docker to make the installation easy.&lt;/p&gt;

&lt;h2&gt;
  
  
  📍 Getting Started
&lt;/h2&gt;

&lt;p&gt;To get started, we need follow this step by step: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install Docker&lt;/li&gt;
&lt;li&gt;Install Nginx Proxy Manager on Docker&lt;/li&gt;
&lt;li&gt;Install Jenkins &amp;amp; Gitlab on Docker&lt;/li&gt;
&lt;li&gt;Add the DNS Manager and set A record subdomain to VPS IP&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;At this post, I using the Ubuntu 22, the installation it's depend on the server you using, but on the main line, it's the same. &lt;/p&gt;

&lt;h3&gt;
  
  
  🔥 Install the docker &amp;amp; docker-compose
&lt;/h3&gt;

&lt;p&gt;First, we install docker with this command: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;apt install docker&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And, we install docker-compose&lt;/p&gt;

&lt;p&gt;&lt;code&gt;apt install docker-compose&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The docker needed to further action like install the Nginx Proxy Manager, Jenkins and Gitlab. So, make sure you install the docker before do another thing. &lt;/p&gt;

&lt;h3&gt;
  
  
  🔥 Install Nginx Proxy Manager on Docker
&lt;/h3&gt;

&lt;p&gt;Docker, check! Next, we install the Nginx Proxy Manager on Docker by using this step by step.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a new directory and add docker-compose.yml file similar to this on your new directory:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '3'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Bring up your stack by running
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Log in to the Admin UI using this default password:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://your-vps-ip:81
Email:    admin@example.com
Password: changeme
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All this step by step is same on the original nginx proxy manager documentation:&lt;br&gt;
&lt;a href="https://nginxproxymanager.com/guide/#quick-setup"&gt;https://nginxproxymanager.com/guide/#quick-setup&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  🔥 Install Jenkins
&lt;/h3&gt;

&lt;p&gt;Okay, nginx proxy manager is already installed, next we need install jenkins on docker. &lt;/p&gt;

&lt;p&gt;You can run this command to install the jenkins on your vps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -d --name jenkins -p 9091:8080 -p 50000:50000 jenkins/jenkins:lts-jdk11
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, your Jenkins will be run on port 8080, you can grep the initial password on the docker logs. &lt;/p&gt;

&lt;p&gt;Navigate to &lt;a href="http://your-vps-ip:9091"&gt;http://your-vps-ip:9091&lt;/a&gt; and setup the Jenkins with the initial password. &lt;/p&gt;

&lt;h3&gt;
  
  
  🔥 Install Gitlab
&lt;/h3&gt;

&lt;p&gt;We successfully install the jenkins and looks like jenkins work perfectly fine, next we need to install gitlab on docker!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run this command for initial before install gitlab
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir -p gitlab; cd gitlab/
mkdir -p /srv/gitlab/{config/ssl,logs,data}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Define the environment variable "GITLAB_HOME" with the value as GitLab data directory "/srv/gitlab" as below.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GITLAB_HOME=/srv/gitlab
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Go to gitlab directory and add docker-compose.yml file similar to this on gitlab directory, edit the domain and hostname:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;web:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  hostname: 'gitlab.yourdomain.com'

  environment:
    GITLAB_OMNIBUS_CONFIG: |
      # Add any other gitlab.rb configuration here, each on its own line
      external_url 'http://gitlab.yourdomain.com'
      gitlab_rails['gitlab_shell_ssh_port'] = 2224

  ports:
    - '8081:80'
    - '4443:443'
    - '2224:22'

  volumes:
    - '${GITLAB_HOME}/config:/etc/gitlab'
    - '${GITLAB_HOME}/logs:/var/log/gitlab'
    - '${GITLAB_HOME}/data:/var/opt/gitlab'
    - '${GITLAB_HOME}/config/ssl:/etc/gitlab/ssl'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Run the installation
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Get the gitlab initial root password by using this command
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  📍 Add the DNS Manager and set A record subdomain to VPS IP
&lt;/h2&gt;

&lt;p&gt;All the application is already installed. Yey! Next, we need to pointing our custom subdomain to our VPS / Nginx Proxy Manager, and we will manage the subdomain on our Nginx Proxy Manager. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to your domain DNS Management, and add the subdomain jenkins, gitlab and pointing to your vps (that we install nginx proxy manager, jenkins, gitlab) like screenshot below. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SAcnHm9A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z2ecevefwmu8v9buwkl5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SAcnHm9A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z2ecevefwmu8v9buwkl5.png" alt="DNS Management" width="880" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to Nginx Proxy Manager, add the subdomain that we already setup earlier and add the your vps IP and Port. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example: We setup the jenkins on port 9091, so we input the your-vps-ip:9091 on the &lt;code&gt;Forward Hostname / IP&lt;/code&gt; sections, as shown on the screenshot below. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FfpHwpYL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0bv7mdv9809zs6r9621h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FfpHwpYL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0bv7mdv9809zs6r9621h.png" alt="Jenkins" width="880" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add the SSL &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Go to SSL tab on the right side and set the SSL as shown on the screenshot below. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9vrJqdMJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ils1e2johb9pqppu009f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9vrJqdMJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ils1e2johb9pqppu009f.png" alt="Jenkins Nginx Proxy Manager" width="498" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And saved the changes. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to your subdomain! &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After that, you just need to navigate to your jenkins subdomain, and you will see the jenkins webservice on your subdomain. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kUs-bJWv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n3r026bwqjn3ykxwd8ad.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kUs-bJWv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n3r026bwqjn3ykxwd8ad.png" alt="Jenkins Nginx Proxy Manager" width="654" height="611"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Great! Mission Success! Now, you can add the gitlab and proxy manager custom subdomain too!&lt;/p&gt;

&lt;h4&gt;
  
  
  🔥 References:
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://forum.gitlab.com/t/how-to-login-for-the-first-time-local-install-with-docker-image/55297"&gt;https://forum.gitlab.com/t/how-to-login-for-the-first-time-local-install-with-docker-image/55297&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.howtoforge.com/how-to-install-gitlab-with-docker-on-ubuntu-2004/"&gt;https://www.howtoforge.com/how-to-install-gitlab-with-docker-on-ubuntu-2004/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://octopus.com/blog/jenkins-docker-install-guide"&gt;https://octopus.com/blog/jenkins-docker-install-guide&lt;/a&gt;&lt;br&gt;
&lt;a href="https://nginxproxymanager.com/guide/#quick-setup"&gt;https://nginxproxymanager.com/guide/#quick-setup&lt;/a&gt;&lt;br&gt;
&lt;a href="https://aksarakode.com/"&gt;https://aksarakode.com/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>gitlab</category>
      <category>jenkins</category>
    </item>
  </channel>
</rss>
