How to use sonar behind nginx proxy not at root?

1,723 views
Skip to first unread message

br...@forceconstant.com

unread,
Dec 22, 2017, 11:22:39 AM12/22/17
to SonarQube
Hello,
I want to setup sonar to be accessable with https://myserver/sonar , but currently that fails to load because it looks like the initial redirect is trying to load java script like /js/app.b06ee6ee.js is using absolute path instead of https://myserver/sonar/js/app.*.js.  I tried setting web context in sonar.properties but that didn't seem to change anything.  Any ideas?

Thanks,
B

Eric Hartmann

unread,
Dec 22, 2017, 12:05:13 PM12/22/17
to br...@forceconstant.com, SonarQube
Hi Brian,

Can you post your reverse proxy configuration ?
Did you configure sonar.web.context in sonar.properties ?

Cheers

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/4bfc403d-cc57-47fa-abe6-5c5e2e155138%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Eric HARTMANN | SonarSource

br...@forceconstant.com

unread,
Dec 22, 2017, 12:52:16 PM12/22/17
to SonarQube
Yes I edited sonar.web.context=/sonar in sonar.properties.

My nginx config is simply below, under main server listing, currently just http on port 80, but will eventually transition to https 

location /sonar/ {
   proxy_pass  http://localhost:9000/;

Eric Hartmann

unread,
Dec 26, 2017, 4:18:33 AM12/26/17
to br...@forceconstant.com, SonarQube
Hi,

Can you try by adding the webcontext to the prox_pass directive ?

location /sonar/ {
   proxy_pass  http://localhost:9000/sonar/;
....

Cheers,



For more options, visit https://groups.google.com/d/optout.

br...@forceconstant.com

unread,
Jan 2, 2018, 7:52:26 AM1/2/18
to SonarQube
No that didn't work.  For example when looking at the source, I see it trying to load <script src="/js/vendor.017c6e7f.js"> which needs to be /sonar/js/...

br...@forceconstant.com

unread,
Jan 18, 2018, 7:57:51 AM1/18/18
to SonarQube
I'm not sure what changed, but sonar and nginix got updated, and it now works.  Maybe I just didn't restart everything correctly.
Thanks,
Reply all
Reply to author
Forward
0 new messages