NGINX with docker? For use with certbot

I’ve been trying to add ssl to my docker instance on google VM. When looking it up on how to do this with cert bot everyone is using nginx. Now looking up how to add nginx to a docker image didn’t help me much nor did looking up how to make an nginx image.

All I want Is to have https on my website. Any and all help is greatly appreciated :slight_smile:

Hello @neddacs
Refer this Docs It will be Help You

The problem with that is it uses docker compose and I have no idea how to hook it up with another docker image

I would try traefik 2.0. I had to use nginx because traefik 1.7 didn’t support TCP routers so I made the following https://github.com/trajano/nginx-letsencrypt

Hi so I have your setup working now, But im getting a fail on
sudo ./init-letsencrypt.sh
the error is

Waiting for verification...
Challenge failed for domain test.txanalytics.com
http-01 challenge for test.txanalytics.com
Cleaning up challenges
Some challenges have failed.

IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: test.txanalytics.com
   Type:   unauthorized
   Detail: Invalid response from
   http://test.txanalytics.com/.well-known/acme-challenge/v151aUhcP1TXLxXSBUFjbCz6tX3k97WWoDSnpkJkuwQ
   [35.209.164.163]: 404

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A/AAAA record(s) for that domain
   contain(s) the right IP address.
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.

Do i need the

.well-known/acme-challenge/v151aUhcP1TXLxXSBUFjbCz6tX3k97WWoDSnpkJkuwQ

on the server when i run the command?

If it helps at a here is my docker compose file

version: '3'
services:
  nginx:
    image: nginx:1.15-alpine
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./data/nginx:/etc/nginx/conf.d
      - ./data/certbot/conf:/etc/letsencrypt
      - ./data/certbot/www:/var/www/certbot
    command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
  certbot:
    image: certbot/certbot
    volumes:
      - ./data/certbot/conf:/etc/letsencrypt
      - ./data/certbot/www:/var/www/certbot
    entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
  web:
    build: .
    ports:
      - "8080:443"

and my directory structure

-base
    -db
    -data
         -certbot
             -conf
             -www
         -nginx
    -dist
         index.html
    -nginx
         app.conf
    build
    cloudbuild.yml
    docker-compose.yaml
    Dockerfile
    init-letsencypt.sh
    runDB
    runServer