Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seems to me that letsencrypt-nginx-proxy-companion is doing its work and that the issue comes from elsewhere : the certificates are correctly generated, are picked up by docker-gen and are included in nginx configuration. #729

Closed
abhimal opened this issue Dec 12, 2020 · 3 comments

Comments

@abhimal
Copy link

abhimal commented Dec 12, 2020

Seems to me that letsencrypt-nginx-proxy-companion is doing its work and that the issue comes from elsewhere : the certificates are correctly generated, are picked up by docker-gen and are included in nginx configuration.

Are you certain your host's port 443 is accessible from the outside ?

Can you curl https://test1.mywebsite.com from the host itself ?

Originally posted by @buchdag in #553 (comment)

curl domain-name.com

RETURN

<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.19.3</center>
</body>
</htm
@buchdag
Copy link
Member

buchdag commented Dec 15, 2020

Hi.

Could you be a bit more specific regarding your issue and maybe change the title to something shorter and relevant ?

Note that I won't provide support for external tutorials, they're their authors responsibility.

@abhimal
Copy link
Author

abhimal commented Dec 16, 2020

sure @buchdag i am new in docker and nginx before it's working fine after updating whenever i run my docker compose
$ docker-compose -f docker-compose.staging.yml up -d --build
i got this errors in my logs
i spent two weeks on it to solve this issue but i couldn't please help me

nginx-proxy                | WARNING: /etc/nginx/dhparam/dhparam.pem was not found. A pre-generated dhparam.pem will be used for now while a new one
nginx-proxy                | is being generated in the background.  Once the new dhparam.pem is in place, nginx will be reloaded.
nginx-proxy                | Generating DSA parameters, 4096 bit long prime
nginx-proxy                | forego     | starting dockergen.1 on port 5000
nginx-proxy                | forego     | starting nginx.1 on port 5100
nginx-proxy                | dockergen.1 | 2020/12/16 06:00:31 Generated '/etc/nginx/conf.d/default.conf' from 3 containers
nginx-proxy                | dockergen.1 | 2020/12/16 06:00:31 Running 'nginx -s reload'
nginx-proxy                | dockergen.1 | 2020/12/16 06:00:31 Watching docker events
nginx-proxy                | dockergen.1 | 2020/12/16 06:00:31 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification 'nginx -s reload'
nginx-proxy                | 2020/12/16 06:00:41 [notice] 83#83: signal process started
nginx-proxy                | dhparam generation complete, reloading nginx
nginx-proxy                | nginx.1    | rkfootwear.in 52.58.118.98 - - [16/Dec/2020:06:00:51 +0000] "GET /.well-known/acme-challenge/81cIcn8bks1Kxfv21-QMUzABl5ipHXL51PHLfQpJnS0 HTTP/1.1" 200 87 "-" "Mozilla/5.0 (compatible; Let's Encrypt validation server; +https://www.letsencrypt.org)"
nginx-proxy                | nginx.1    | rkfootwear.in 18.224.20.83 - - [16/Dec/2020:06:00:51 +0000] "GET /.well-known/acme-challenge/81cIcn8bks1Kxfv21-QMUzABl5ipHXL51PHLfQpJnS0 HTTP/1.1" 200 87 "-" "Mozilla/5.0 (compatible; Let's Encrypt validation server; +https://www.letsencrypt.org)"
nginx-proxy                | nginx.1    | rkfootwear.in 34.211.60.134 - - [16/Dec/2020:06:00:51 +0000] "GET /.well-known/acme-challenge/81cIcn8bks1Kxfv21-QMUzABl5ipHXL51PHLfQpJnS0 HTTP/1.1" 200 87 "-" "Mozilla/5.0 (compatible; Let's Encrypt validation server; +https://www.letsencrypt.org)"
nginx-proxy                | nginx.1    | rkfootwear.in 66.133.109.36 - - [16/Dec/2020:06:00:51 +0000] "GET /.well-known/acme-challenge/81cIcn8bks1Kxfv21-QMUzABl5ipHXL51PHLfQpJnS0 HTTP/1.1" 200 87 "-" "Mozilla/5.0 (compatible; Let's Encrypt validation server; +https://www.letsencrypt.org)"
nginx-proxy                | nginx.1    | 2020/12/16 06:02:04 [error] 147#147: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 217.27.176.227, server: rkfootwear.in, request: "HEAD /.git/config HTTP/1.1", upstream: "http://192.168.64.2:8000/.git/config", host: "rkfootwear.in"

thsi is my yml fiel docker-compose.staging.yml

version: '3.7'

services:
  web:
    build:
      context: ./app
      dockerfile: Dockerfile.prod
    command: gunicorn buznestBackend.wsgi:application --bind 0.0.0.0:8000
    volumes:
      - static_volume:/home/app/web/staticfiles
      - media_volume:/home/app/web/mediafiles
    expose:
      - 8000
    env_file:
      - .env.staging
  nginx-proxy:
    container_name: nginx-proxy
    build: nginx
    restart: always
    ports:
      - 443:443
      - 80:80
    volumes:
      - static_volume:/home/app/web/staticfiles
      - media_volume:/home/app/web/mediafiles
      - certs:/etc/nginx/certs
      - html:/usr/share/nginx/html
      - vhost:/etc/nginx/vhost.d
      - /var/run/docker.sock:/tmp/docker.sock:ro
    depends_on:
      - web
  nginx-proxy-letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    env_file:
      - .env.staging.proxy-companion
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - certs:/etc/nginx/certs
      - html:/usr/share/nginx/html
      - vhost:/etc/nginx/vhost.d
    depends_on:
      - nginx-proxy

volumes:
  static_volume:
  media_volume:
  certs:
  html:
  vhost:

my nginx directory look like this

└── nginx
├── Dockerfile
├── custom.conf
└── vhost.d
└── default

  • inside vhost.d directory add a file called default file
location /staticfiles/ {
  alias /home/app/web/staticfiles/;
  add_header Access-Control-Allow-Origin *;
}

location /mediafiles/ {
  alias /home/app/web/mediafiles/;
  add_header Access-Control-Allow-Origin *;
}
  • Dockerfile
FROM jwilder/nginx-proxy
COPY vhost.d/default /etc/nginx/vhost.d/default
COPY custom.conf /etc/nginx/conf.d/custom.conf
  • custom.conf
    client_max_body_size 10M;

@buchdag
Copy link
Member

buchdag commented Dec 26, 2020

before it's working fine after updating whenever i run my docker compose i got this errors in my logs

I guess that's after updating the companion container, right ?

You need a new Docker volume attached to /etc/acme.sh on the companion container.

There's a bit more info on the README:

Required read if you use the latest version : the recent v2.0.0 release of this project mark the switch of the ACME client used by the Docker image from simp.le to acme.sh. This switch result in some backward incompatible changes, so please read this issue and the updated docs for more details before updating your image. The single most important change is that the container now requires a volume mounted to /etc/acme.sh in order to persist ACME account keys and SSL certificates. The last tagged version that uses simp_le is v1.13.1.

@abhimal abhimal closed this as completed Dec 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants