Tutorials  /  Linux Basics

How to Install and Secure GoCD on CentOS 7 with SSL and Firewall

Ccentron Redaktion · July 2025 ·9 min read ·Linux Basics, Tutorial

GoCD is a freely available automation and continuous delivery platform. It supports designing sophisticated pipelines through both sequential and concurrent task execution. Its integrated value stream mapping simplifies the visualization of complex deployment chains. You can inspect and compare builds effortlessly and deploy specific application versions as needed.

The GoCD environment comprises a server and agents. The server handles administrative tasks such as delivering jobs to agents and offering a web-based interface. Meanwhile, agents execute assigned jobs and manage deployments.

Requirements

  • A CentOS 7 server with a minimum of 1GB RAM
  • An account with sudo privileges
  • A domain that routes traffic to the server

For demonstration purposes, this guide uses the IP 192.168.1.1 and domain gocd.example.com. Make sure to update these with your actual IP and domain details.

Before continuing, refer to the guide on updating CentOS 7 to ensure your system is up to date. Once completed, proceed to install Java.

VM

Matching infrastructure at centron

No hardware needed to follow along: ccloud³ VMs with full root access start at €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

Java Installation

GoCD requires Java 8, and it’s compatible with both OpenJDK and Oracle Java. This guide uses OpenJDK 8, which is accessible via the standard YUM repository.

Run the following to install Java:

Console
sudo yum -y install java-1.8.0-openjdk-devel

To verify the Java installation:

Code
java -version

Example output:

Code
[user@centron~]$ java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

To configure Java environment variables, find the absolute path of the Java binary:

Code
readlink -f $(which java)

Expected output:

Code
[user@centron~]$ readlink -f $(which java)
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64/jre/bin/java

Now, define the JAVA_HOME and JRE_HOME variables using your system’s path:

Console
echo "export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64" >> ~/.bash_profile
echo "export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64/jre" >> ~/.bash_profile

Note: Replace the paths with your specific installation directory as they may vary with newer releases.

Apply the profile changes:

Code
source ~/.bash_profile

Verify the variable:

Code
[user@centron~]$ echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-1.b12.el7_4.x86_64

Installing GoCD

As GoCD is Java-based, Java must be installed first. To proceed, integrate the official GoCD repository:

Console
sudo curl https://download.gocd.org/gocd.repo -o /etc/yum.repos.d/gocd.repo

Then install the GoCD server:

Console
sudo yum install -y go-server

Start and enable the service at boot:

Console
sudo systemctl start go-server
sudo systemctl enable go-server

Create a directory for storing build artifacts:

Console
sudo mkdir /opt/artifacts
sudo chown -R go:go /opt/artifacts

Configuring Block Storage

Since CI/CD systems like GoCD continuously generate files, it’s recommended to allocate a separate partition for artifact storage. This avoids storage-related service disruptions as disk usage grows.

If opting for separate storage, attach a block device and create a partition:

Console
sudo parted -s /dev/vdb mklabel gpt
sudo parted -s /dev/vdb unit mib mkpart primary 0% 100%

Format the partition:

Console
sudo mkfs.ext4 /dev/vdb1

Mount the disk and configure it for persistence:

Console
sudo mkdir /mnt/artifacts
sudo cp /etc/fstab /etc/fstab.backup
echo "
/dev/vdb1 /mnt/artifacts ext4 defaults,noatime 0 0" | sudo tee -a /etc/fstab
sudo mount /mnt/artifacts

Use df to confirm the mount:

Code
[user@centron~]$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/vda1       20616252 6313892  13237464  33% /

...
/dev/vdb1       10188052   36888   9610596   1% /mnt/artifacts

Assign GoCD as the owner of the mount point:

Console
sudo chown -R go:go /mnt/artifacts

Firewall Configuration

Allow network traffic on GoCD's default ports 8153 (non-secure) and 8154 (secure) by updating the firewall settings:

Console
sudo firewall-cmd --zone=public --add-port=8153/tcp --permanent
sudo firewall-cmd --zone=public --add-port=8154/tcp --permanent
sudo firewall-cmd --reload

Now, open http://192.168.1.1:8153 for non-encrypted access or https://192.168.1.1:8154 for encrypted access. You might see a warning about invalid certificates—this can be disregarded since the certificate is self-signed. It's strongly recommended to use the secure URL.

Navigate to Admin >> Server Configuration in the GoCD dashboard and provide:

  • The HTTP site URL (non-secure)
  • The HTTPS site URL (secure)
  • Your SMTP mail server configuration (for notifications)
  • The path to store artifacts: use /opt/artifacts or /mnt/artifacts depending on where you've set up storage

To automatically delete older artifacts, configure this option based on your disk capacity. Keep in mind that enabling this option does not back up artifacts. If backups are required, set auto-delete to "Never" and manage it manually.

To apply your changes, restart the GoCD service:

Console
sudo systemctl restart go-server

Setting Up Password Authentication

By default, GoCD lacks user authentication. It can be secured using password files or LDAP. This tutorial sets up a password-based login system.

Important: This is optional, but highly advisable for publicly accessible installations.

Begin by installing the Apache tools package:

Console
sudo yum -y install httpd-tools

Create the password file and define an admin user:

Console
sudo htpasswd -B -c /etc/go/passwd_auth goadmin

You'll be prompted to enter and confirm the password. To add more users without overwriting existing ones, skip the -c flag:

Console
sudo htpasswd -B /etc/go/passwd_auth gouser1

Log back into the dashboard and navigate to Admin >> Security >> Authorization Configurations. Click "Add", set an ID, select "Password File Authentication Plugin for GoCD", and specify the file path.

Test the configuration by clicking "Check Connection" and save the settings. You'll be logged out and see a login prompt—sign in with your new credentials.

To assign admin rights, go to Admin >> User Summary, select the admin account, and mark "Go System Administrator" under roles.

Users are added either manually or automatically upon first login if they are present in the password file.

Securing GoCD Using Let's Encrypt and Nginx

Though GoCD already supports secure connections on port 8154, browsers may show warnings because of the self-signed certificate. To prevent this, install Let's Encrypt with Nginx acting as a reverse proxy.

First, install and configure Nginx:

Console
sudo yum -y install nginx
sudo systemctl start nginx
sudo systemctl enable nginx

Install Certbot to obtain SSL certificates:

Console
sudo yum -y install certbot

Allow HTTP and HTTPS traffic and remove port 8153 from the firewall:

Console
sudo firewall-cmd --zone=public --add-service=http --permanent
sudo firewall-cmd --zone=public --add-service=https --permanent
sudo firewall-cmd --zone=public --remove-port=8153/tcp --permanent
sudo firewall-cmd --reload

Note: Ensure your domain resolves to the server before proceeding with certificate issuance.

Request certificates:

Console
sudo certbot certonly --webroot -w /usr/share/nginx/html -d gocd.example.com

The files will be placed in /etc/letsencrypt/live/gocd.example.com/.

Set up daily auto-renewal using cron:

Console
sudo crontab -e

Add:

Code
30 5 * * * /usr/bin/certbot renew --quiet

Remove the default_server directive from Nginx’s main config:

Console
sudo sed -i 's/default_server//g' /etc/nginx/nginx.conf

Create the GoCD virtual host file:

Console
sudo nano /etc/nginx/conf.d/gocd.conf

Insert the following content:

Code
upstream gocd {
  server 127.0.0.1:8153;
}

server {
  listen 80 default_server;
  server_name gocd.example.com;
  return 301 https://$host$request_uri;
}

server {
  listen 443 default_server;
  server_name gocd.example.com;

  ssl_certificate /etc/letsencrypt/live/gocd.example.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/gocd.example.com/privkey.pem;

  ssl on;
  ssl_session_cache builtin:1000 shared:SSL:10m;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
  ssl_prefer_server_ciphers on;

  access_log /var/log/nginx/gocd.access.log;

  location / {
    proxy_pass http://gocd;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    proxy_redirect off;
  }

  location /go {
    proxy_pass http://gocd/go;
    proxy_http_version 1.1;
    proxy_set_header Upgrade websocket;
    proxy_set_header Connection upgrade;
    proxy_read_timeout 86400;
  }
}

Check for configuration errors:

Console
sudo nginx -t

If validation passes, restart Nginx:

Console
sudo systemctl restart nginx

Open https://gocd.example.com and update your Server Configuration URLs accordingly. Keep port 8154 accessible so agents can connect if needed.

Installing the GoCD Agent

GoCD agents carry out the CI tasks and pipeline executions. When changes are detected, jobs are dispatched to these agents for execution.

Install an agent using YUM:

Console
sudo yum install -y go-agent

Enable and start the agent service:

Console
sudo systemctl start go-agent
sudo systemctl enable go-agent

Once installed on the local server, the agent will automatically appear in the GoCD dashboard as an active worker.

Conclusion

By following this guide, you've successfully set up a fully functional GoCD continuous delivery environment on CentOS 7. You’ve installed and configured Java, the GoCD server, and agent, and secured your deployment using Let's Encrypt SSL with Nginx as a reverse proxy. You’ve also configured authentication for secure access and established proper artifact storage and firewall rules to ensure stability and performance.

This setup enables you to build and manage sophisticated deployment pipelines with clarity and flexibility. Be sure to regularly maintain your SSL certificates, monitor artifact storage usage, and keep your system updated to ensure ongoing reliability and security.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Linux Basics
Teilen
Noch offene Fragen?

Our team will help you with your specific setup - in German or English, by people who run the platform themselves.

War dieses Tutorial hilfreich?

Your answer is stored anonymously and helps us improve our tutorials.

Kommentare

No comments yet - be the first to ask a question about this tutorial.

Sign in to comment

Comments are open to centron customers. Sign in to your account to ask a question about this tutorial.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren