DEV Community

Cover image for Assigning a Domain Name to Your Service with Apache Reverse Proxy on Ubuntu (Jenkins, SonarQube, Grafana, etc.)
Durrell  Gemuh
Durrell Gemuh

Posted on

Assigning a Domain Name to Your Service with Apache Reverse Proxy on Ubuntu (Jenkins, SonarQube, Grafana, etc.)

When you deploy services like Jenkins (8080), SonarQube (9000), or Grafana (3000), by default they run on high ports.
Accessing them looks like this:

http://your-server-ip:8080   # Jenkins
http://your-server-ip:9000   # SonarQube
http://your-server-ip:3000   # Grafana
Enter fullscreen mode Exit fullscreen mode

That’s not ideal. Instead, you want:

https://jenkins.example.com
https://sonarqube.example.com
https://grafana.example.com
Enter fullscreen mode Exit fullscreen mode

The solution: use Apache HTTP Server as a reverse proxy to map domain names (on port 80/443) to services running on their custom ports.

Prerequisites

  • A server (VM, bare metal, or cloud instance like GCP/AWS/Azure) running Ubuntu 20.04/22.04 with:
    • Apache 2.4+
  • A registered domain/subdomains (example.com) pointing to your server’s public IP via DNS.
  • Your applications (Jenkins, SonarQube, Grafana, etc.) already running on ports like 8080, 9000, 3000.

Step 1: Install Apache & Required Modules

sudo apt update
sudo apt install apache2 -y
sudo a2enmod proxy proxy_http headers ssl
sudo systemctl restart apache2
Enter fullscreen mode Exit fullscreen mode

Step 2: Create Virtual Hosts for Each Service

Each subdomain gets its own Apache site config.

Example: Jenkins on jenkins.example.com

sudo nano /etc/apache2/sites-available/jenkins.conf
Enter fullscreen mode Exit fullscreen mode
<VirtualHost *:80>
    ServerName jenkins.example.com

    ProxyPreserveHost On
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/

    ErrorLog ${APACHE_LOG_DIR}/jenkins_error.log
    CustomLog ${APACHE_LOG_DIR}/jenkins_access.log combined
</VirtualHost>
Enter fullscreen mode Exit fullscreen mode

Example: SonarQube on sonarqube.example.com

sudo nano /etc/apache2/sites-available/sonarqube.conf
Enter fullscreen mode Exit fullscreen mode
<VirtualHost *:80>
    ServerName sonarqube.example.com

    ProxyPreserveHost On
    ProxyPass / http://localhost:9000/
    ProxyPassReverse / http://localhost:9000/

    ErrorLog ${APACHE_LOG_DIR}/sonarqube_error.log
    CustomLog ${APACHE_LOG_DIR}/sonarqube_access.log combined
</VirtualHost>
Enter fullscreen mode Exit fullscreen mode

Example: Grafana on grafana.example.com

sudo nano /etc/apache2/sites-available/grafana.conf
Enter fullscreen mode Exit fullscreen mode
<VirtualHost *:80>
    ServerName grafana.example.com

    ProxyPreserveHost On
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/

    ErrorLog ${APACHE_LOG_DIR}/grafana_error.log
    CustomLog ${APACHE_LOG_DIR}/grafana_access.log combined
</VirtualHost>
Enter fullscreen mode Exit fullscreen mode

Step 3: Enable Sites & Reload Apache

sudo a2ensite jenkins.conf sonarqube.conf grafana.conf
sudo apache2ctl configtest
sudo systemctl reload apache2
Enter fullscreen mode Exit fullscreen mode

Now, visiting:

  • http://jenkins.example.com
  • http://sonarqube.example.com
  • http://grafana.example.com

…should load your apps without ports in the URL

No more ugly :8080, :9000, or :3000.
All services accessible securely under their own subdomains.

Why Use Apache Reverse Proxy?

  • Cleaner, professional URLs
  • Hide internal ports from external users
  • Easy scaling to more apps (just add another <VirtualHost> block)

With this setup, you can expose any service (Jenkins, SonarQube, Grafana, Dependency-Track, etc.) securely on its own domain.

This was just the HTTP setup, stay tuned for Part 2, where we’ll cover enabling SSL for a secure connection.

Top comments (0)