SonarQube Community 10.4.1 doesn't load when behind nginx reverse proxy + cloudflare

I have set up an instance of SonarQube Community using Docker and I’m making it available on a publically accessible URL by using an NGINX reverse proxy going through CloudFlare but after initial setup whenever I try to go to the URL I am faced with an infinite loading screen and a JavaScript parsing error in the console. I’ve tried 3 browsers (Vivaldi, Firefox, Safari) both regular tabs and ingonito tabs and in the case of the former 2 also with all “blocking” type extensions disabled.

The error I get is:

Uncaught SyntaxError: Invalid or unexpected token (at outBIMYN2XL.js:1:7186)

My NGINX config is:

upstream sonarqube.sapphirejs {
    server 127.0.0.1:9000;
    keepalive 8;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2 default_server;

    server_name sonarqube.sapphirejs.dev;

    access_log /somelog;

    ssl_certificate /myfile.pem;
    ssl_certificate_key /apath.key;

    location / {
        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_pass http://sonarqube.sapphirejs/;
        proxy_redirect off;
    }
}

My Cloudflare is set to “proxy” type for the A DNS record going to https://sonarqube.sapphirejs.dev.

Notably when I access the server through the public IPv4 address directly then it does work fine.

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension): 10.4.1
  • how is SonarQube deployed: zip, Docker, Helm: Docker
  • what are you trying to achieve: Logging in
  • what have you tried so far to achieve this: See above

Hey there.

Are you still facing the issue? I’m browsing https://sonarqube.sapphirejs.dev/ just fine. Or are you trying to access it at http://sonarqube.sapphirejs/ (I’m having trouble understanding how that would work, since .sapphirejs isn’t a TLD. Let me know if I’m missing something.

I have this issue too, my sonarqube with proxied enabled and the site is stuck at infinite loading screen with same error in console Uncaught SyntaxError: Invalid or unexpected token (at outBIMYN2XL.js:1:7186)

Anyways just fixed the issue with Cloudflare page rules with Cache Bypass trick. I just found that my JS was being cut that turns out blocking javascript.

Reference: https://community.cloudflare.com/t/cloudflare-breaking-js-and-css/327148/17