How Do You Access the SonarQube Web UI When It Is Only Listening on the 127.0.0.1 IP Address?

Problem scenario
SonarQube is listening on the loopback IP address on port 9000.  SonarQube is not listening on the external IP address.   You want to access the web UI for SonarQube. What should you do?

Solution
Install a web server and configure it to connect to port 9000.  Here are the details for using Apache web server on a Red Hat derivative (e.g., CentOS/RHEL/Fedora).

1.  Run this command:  sudo yum -y install httpd

2.a  Run this command, but replace x.x.x.x with the external IP address of your server (or the URL that you will present with this server):  

sudo vi /etc/httpd/conf.d/sonar.x.x.x.x.conf

2.b.  Place these lines in the file (where the top and bottom lines have "VirtualHost" in them):

<VirtualHost *:80>
    ServerName sonar.x.x.x.x
    ServerAdmin admin@continualintegration.com
    ProxyPreserveHost On
    ProxyPass / http://localhost:9000/
    ProxyPassReverse / http://localhost:9000/
    TransferLog /var/log/httpd/sonar.x.x.x.x_access.log
    ErrorLog /var/log/httpd/sonar.x.x.x.x_error.log
</VirtualHost>

2.c.  Replace x.x.x.x with the IP address or domain name of your server.

2.d.  Replace "admin@continualintegration.com" with an email address of yours.

3.  Run these two commands:

sudo systemctl start httpd
sudo systemctl enable httpd

Leave a comment

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