2
votes

We are trying to run sonarqube behind a reverse proxy (nginx).

We have nginx running on once instance within our AWS VPC, and sonarqube on another instance. Below is our sonarqube location block. NGINX is set to listen on port 80…

Sonarqube is running in a docker container with port 9000 mapped to 9000 on the host.

Our default location (below) redirects anything other than a valid location to the jira location. When we try to access sonarqube using the address of the machine running NGINX and /sonarqube, we just get redirected to Jira.

It is worth noting that all our other applications that have a location block in the nginx config work as expected.

location / {
                return 301 /jira;
        }
location /sonarqube {
        proxy_pass                           http://<ip-address of machine running sonarqube>:9000/sonarqube;
        proxy_set_header X-Forwarded-Host    $host;
        proxy_set_header X-Forwarded-Server  $host;
        proxy_set_header X-Forwarded-For     $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP           $remote_addr;
        proxy_redirect                       off;
        client_max_body_size                 8m;
        client_body_buffer_size              128k;
    }
1
Did you ever find an answer to this question? If you did, it would be cool if you put the solution on here. Thank you. - Edward Kennedy

1 Answers

0
votes

Is your sonar.properties correctly configured?

sonar.web.port:                           9000
sonar.web.context:                        /sonarqube

After that you can change your nginx config as

    location /sonarqube {
        proxy_pass         http://<sonarqube_ip>:9000;
        ...
    }