Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SonarQube under Nginx sub-location

Has I try to create a continuous integration server, i have many tools to install, but i want to use a single DN for all of it. So I'm trying to host each tool under a sub-location of my DN (ex : my-domain.org/sonar, my-domain.org/packages, etc...)

As an hosting newbie, I'm facing a very boring issue, with SonarQube access. The tool is installed, and i can access it with my-domain.org:9000

But my Nginx configuration does not seems to be convenient, has the expected SonarQube page gives me a SonarQube 404.

Here is my Nginx vhost configuration :

server {
  listen *:80;
  server_name my-domain.org;

  #some other tools configuration

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

Any help will be appreciated. Thank you

like image 364
Yann Eugoné Avatar asked Sep 22 '14 15:09

Yann Eugoné


1 Answers

I faced the exact same issue today and solved it with the configurations below. The problem though, depending on your configuration of sonarqube this could be slightly different, but here we go:

sonar.properties

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

sites-available/default.conf

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

  # set header
  proxy_set_header        Host $host;
  proxy_set_header        X-Real-IP $remote_addr;
  proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_connect_timeout   150;
  proxy_send_timeout      100;
  proxy_read_timeout      100;
  proxy_buffers           4 32k;
  client_max_body_size    8m;
  client_body_buffer_size 128k;

   proxy_redirect http://localhost:9000 http://$yourlan$/sonarqube;
}

Nginx server should listen on Port 80 and server_name should be $yourlan$

like image 176
maiksensi Avatar answered Oct 13 '22 13:10

maiksensi