Using https: with Docker

Configuring SSL on Nginx is fairly simple (especially if you have the cert files already); I can help with that if needed. Hopefully this will offer a foundation for what you’re wanting to build:

Before starting out, create the docker network to which the ‘metabase-app’ and ‘nginx-proxy’ containers will eventually connect:

docker network create proxy-network

Since you already have metabase containers (let’s say they’re metabase-app and metabase-db), adding the app to the new network can be accomplished as follows:

docker network connect proxy-network metabase-app

Now, let’s run an nginx container (but this will require some setup, per the example file that follows):

docker run -d --restart always -p 80:80 -v /host/path/to/conf.d:/etc/nginx/conf.d --network proxy-network --name nginx-proxy nginx

I’m proxying to multiple containerized services, but maybe you only need something called metabase.conf in your conf.d. (note: the nginx container is looking for files that end in .conf)

Here’s an example metabase.conf:

upstream metabase-service {
  server metabase-app:3000;
}

server {
  server_name metabase.example.org;
  listen 80;

  location / {
    proxy_pass http://metabase-service;
    proxy_redirect off;
    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_set_header X-Forwarded-Host $server_name;
  }
}

nginx can be further configured to support SSL – and these two containers can be isolated on virtual networks; you won’t need to bind the docker container’s ports to the host machine, and nginx can proxy to the metabase-app container.

2 Likes