Sonarqube session behind proxy impossible to connect

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • what are you trying to achieve
  • what have you tried so far to achieve this

I installed succesfully Sonarqube developer edition on a production server.

Installation : Sonarqube 8.4.1-developer with docker. Image name ‘sonarqube:8.4.1-developer’
I can successfully connect Sonarqube in local with my local connection :

meaning when I enter http://192.168.15.29:9000 --> I can see Sonarqube web interface and log in etc …etc… No probleme here.

Where I face a problem is when I try to acces sonarqube web interface from public internet with for example address :

https://my_public_Name.com/sonarqube

I have an apache proxy where I added following line in my <Virtual Host *:443> section :
ProxyPass /sonarqube http://192.168.15.29:9000
ProxyPassReverse /sonarqube http://192.168.15.29:9000

When I try to connect the address :

I’m stuck with an infinite page “Loading” as shown below :

image

Link seems to “almost” be working but not totaly. Am I missing something in Sonarqube configuration ?

My docker yml file composition is the one below :

Hi there,

Thanks for sharing this information. It would be beneficial to get:

  • Your full configuration on Apache Proxy side, i.e. the full <Virtual Host *:443> block
  • The server logs (web.log, ce.log, access.log), coinciding with the time at which you experienced this issue.

This will help pointing out the precise root cause. However, given your scenario, let me give you a few hints as pointed out in our documentation about setting up SonarQube behind a Proxy & using HTTPS:

  • You need to have ProxyPreserveHost On directive so that the hostname of the request is passed to SonarQube server.
  • You must also include the directive RequestHeader set X-Forwarded-Proto https, otherwise the redirection will fall back to HTTP.

Let me know if the above helps. Otherwise, please share the logs and information I pointed out above so that we can dig deeper.

Cheers,
Daniel

Hi there,

Effectively your advice was good and help me for one part of the problem.

I found alone also that in case of a proxy where the web context is needed to redirect correctly the request to the sonar server, you know the “/personal_text_here” after the public adress (the /sonarqube in my case), a sonarqube additionnal setting need to be done in the sonar docker. This setting is to be done in the “sonar.web.context” property

This can be “normally” done via ENV variables but this doesn’t work… See following issue similar to mine :

I also searched for another way to edit the “sonar.web.context” property and found my solution here after days of search…

Conclusion : the lines that has to be added in the proxy conf (available in my first post above) is :

RequestHeader set X-Forwarded-Port "443"
RequestHeader set X-Forwarded-Proto "https"

And the line to add in the docker compose yml file in order to add the web context “/sonarqube” to each reply of the inner server in the sonarqube server is :

command: -Dsonar.web.context=/sonarqube

–> this way proxy redirect correctly all the request in both direction now.

Hope it can help other.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.