Sonarqube with Nginx sub-location not loading js/css files

Viewed 227

When I am trying to access SERVER_IP:9000 from browser, sonarqube is loading perfectly fine.

Whereas for SERVER_IP/sonarqube, I am getting this error:

Failed to load resource: the server responded with a status of 404 (Not Found) vendors-main.m.428bef42.chunk.js:1

Error image

Here is my nginx.conf file:

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include             mime.types;
    default_type        application/octet-stream;
    sendfile            on;
    keepalive_timeout   65;

    server {
        listen 80;

        location / {
            #root       html;
            #index      index.html index.htm;
            proxy_pass  http://localhost:8080/;
        }

        location = /sonarqube {
            proxy_pass  http://localhost:9000/;
        }

        error_page      500 502 503 504  /50x.html;
        location = /50x.html {
            root        html;
        }

        location ~ \.css {
            add_header  Content-Type    text/css;
        }
        location ~ \.js {
            add_header  Content-Type    application/x-javascript;
        }
    }
}

Any help will be appreciated. Thank you.

1 Answers

You need to give the context which you have configured on Nginx on sonar.properties file.

Go to, sonar.properties file and give sonar.web.context value as per your nginx context configuration

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

Now restart sonarqube. it will work!

Related