Docker-sonarqube: How to setup reverse proxy for HTTPS

Created on 5 Feb 2018  ·  3Comments  ·  Source: SonarSource/docker-sonarqube

Hi all,

Sorry for posting this here, but I simply don't understand how to setup a reverse proxy for HTTPS.
I've seen this documentation page (https://docs.sonarqube.org/display/SONAR/Securing+the+Server+Behind+a+Proxy), but it isn't clear to me how to set it up for the Docker implementation.

So I setup a Ubuntu server, installed Docker and followed these steps: https://github.com/SonarSource/docker-sonarqube/blob/master/recipes.md

Now I have SonarQube up and running and I can access it through http://{ server-IP }:9000

But how can I make SonarQube accessible through a custom domainname. So for example: https://sonarqube.example.com

Do I need to install NGINX on Ubuntu, or do I need to change the docker-compose.yml to start an NGINX container?

I don't know if it changes anything, but I use Cloudflare to configure the DNS and to add HTTPS.

question

Most helpful comment

I've seen this documentation page (https://docs.sonarqube.org/display/SONAR/Securing+the+Server+Behind+a+Proxy), but it isn't clear to me how to set it up for the Docker implementation.

Now I have SonarQube up and running and I can access it through http://{ server-IP }:9000
But how can I make SonarQube accessible through a custom domainname. So for example: https://sonarqube.example.com

The same way as usage of Nginx to serve https requests for some domain and any other container.

Do I need to install NGINX on Ubuntu, or do I need to change the docker-compose.yml to start an NGINX container?

It's entirely up to you - can do one or another depending on what you want to achieve.

And strictly speaking explanations of Nginx and how to use Docker are off-topic of this bug tracker, but nevertheless below is an example of second way.

docker-compose.yml:

version: "2"

services:
  sonarqube:
    image: sonarqube
    networks:
      - sonarnet
  nginx:
    build:
      context: .
      dockerfile: Dockerfile.nginx
    ports:
      - "8080:80"
    networks:
      - sonarnet

networks:
  sonarnet:
    driver: bridge

Dockerfile.nginx:

FROM nginx
COPY nginx-sonarqube.conf /etc/nginx/conf.d/sonarqube.conf

nginx-sonarqube.conf:

server {
  server_name example.org;
  location / {
    proxy_pass http://sonarqube:9000;
  }
}

and in /etc/hosts I have 127.0.0.1 example.org, so that after docker-compose up I can see SonarQube homepage on http://example.org:8080 as it is proxied via Nginx to SonarQube.

All 3 comments

I've seen this documentation page (https://docs.sonarqube.org/display/SONAR/Securing+the+Server+Behind+a+Proxy), but it isn't clear to me how to set it up for the Docker implementation.

Now I have SonarQube up and running and I can access it through http://{ server-IP }:9000
But how can I make SonarQube accessible through a custom domainname. So for example: https://sonarqube.example.com

The same way as usage of Nginx to serve https requests for some domain and any other container.

Do I need to install NGINX on Ubuntu, or do I need to change the docker-compose.yml to start an NGINX container?

It's entirely up to you - can do one or another depending on what you want to achieve.

And strictly speaking explanations of Nginx and how to use Docker are off-topic of this bug tracker, but nevertheless below is an example of second way.

docker-compose.yml:

version: "2"

services:
  sonarqube:
    image: sonarqube
    networks:
      - sonarnet
  nginx:
    build:
      context: .
      dockerfile: Dockerfile.nginx
    ports:
      - "8080:80"
    networks:
      - sonarnet

networks:
  sonarnet:
    driver: bridge

Dockerfile.nginx:

FROM nginx
COPY nginx-sonarqube.conf /etc/nginx/conf.d/sonarqube.conf

nginx-sonarqube.conf:

server {
  server_name example.org;
  location / {
    proxy_pass http://sonarqube:9000;
  }
}

and in /etc/hosts I have 127.0.0.1 example.org, so that after docker-compose up I can see SonarQube homepage on http://example.org:8080 as it is proxied via Nginx to SonarQube.

Just wanted to drop by and say that the example posted above was super helpful.

Hi, I keep having an infinite loop with https.

What are the requirement for http vhost ?

Was this page helpful?
0 / 5 - 0 ratings