gilyes / docker-nginx-letsencrypt-sample

Dockerized Nginx + Let's Encrypt sample
https://gilyes.com/docker-nginx-letsencrypt
385 stars 185 forks source link

FYI #2

Open 1beb opened 7 years ago

1beb commented 7 years ago

There's a problem with the latest version of jrcs/letsencrypt-nginx-proxy-companion so I used the one that I assumed you would have used 4 months ago based on your commit (v1.4) to get your examples working. They worked!

All I had to do was change the image to:

jrcs/letsencrypt-nginx-proxy-companion:v1.4

pavelsr commented 7 years ago

Hi,

Same problem, sample doesn't work with latest jrcs/letsencrypt-nginx-proxy-companion image, when I try access VIRTUAL_HOST / LETSENCRYPT_HOST domain is showing me default http (not https) nginx page instead of main page of sample site:

sample

No error on nginx logs, just 200/304 HTTP code. When I'm trying to access site with https I got ERR_CONNECTION_REFUSED error and even no one string in log about it!

However problem also wasn't solved by changing image to jrcs/letsencrypt-nginx-proxy-companion:v1.4

gilyes commented 7 years ago

It (eventually) worked for me on a new server using the latest images. It took more than 5 minutes (in addition to the initial DH generation) to generate the certificates.

Part of that delay was about 2 minutes for each service to get to an error like

Unable to reach http://sample.mydomain.com/.well-known/acme-challenge/NCpWTlcsHysVza9GzclhOUp8zEN_jR0F7XIX_KlHlYE

even though I was actually able to manually load that URL during that time. Others are seeing the same issue: https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion/issues/209

After these errors though the certificates got created anyway.

pavelsr commented 7 years ago

I suspect that something wrong with nginx.tmpl. But no idea how to debug, asked on stack, but no one reply for now.

I found in logs such string:

2017/06/02 12:43:18 [emerg] 1#1: no servers are inside upstream in /etc/nginx/conf.d/default.conf:36

My docker-compose file:

version: "2"

services:
  nginx:
    restart: always
    image: nginx
    container_name: nginx
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "/etc/nginx/conf.d"
      - "/etc/nginx/vhost.d"
      - "/usr/share/nginx/html"
      - "./certs:/etc/nginx/certs:ro"
    networks:
      - proxy-tier

  nginx-gen:
    restart: always
    image: jwilder/docker-gen
    container_name: nginx-gen
    volumes:
      - "/var/run/docker.sock:/tmp/docker.sock:ro"
      - "./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro"
    volumes_from:
      - nginx
    entrypoint: /usr/local/bin/docker-gen -notify-sighup nginx -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf

  letsencrypt-nginx-proxy-companion:
    restart: always
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: letsencrypt-nginx-proxy-companion
    volumes_from:
      - nginx
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - "./certs:/etc/nginx/certs:rw"
    environment:
      - NGINX_DOCKER_GEN_CONTAINER=nginx-gen

networks:
  proxy-tier:
    external:
      name: nginx-proxy