网站无法访问使用docker-compose,nginx-proxy和let加密

时间:2017-06-21 14:31:53

标签: docker-compose lets-encrypt hexo jwilder-nginx-proxy

无法使用docker-composenginx-proxyletsencrypt设法访问我的网站...我正在关注本教程:https://github.com/fatk/docker-letsencrypt-nginx-proxy-companion-examples

这是我的配置(当然example.com不是我正在使用的值):

./docker-compose.yml

version: "2"

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

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

  letsencrypt-nginx-proxy-companion:
    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"
      - "./volumes/proxy/certs:/etc/nginx/certs:rw"
    environment:
      - NGINX_DOCKER_GEN_CONTAINER=nginx-gen

  blog:
    image: nginx
    container_name: blog
    volumes:
      - "./volumes/blog/conf.d/:/etc/nginx/conf.d"
      - "./volumes/blog/public/:/usr/share/nginx/html"
    environment:
      - VIRTUAL_HOST=example.com
      - VIRTUAL_NETWORK=nginx-proxy
      - VIRTUAL_PORT=80
      - LETSENCRYPT_HOST=example.com
      - LETSENCRYPT_EMAIL=contact@example.com
    networks:
      - proxy-tier

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

./volumes/blog/conf.d/blog.conf

server {
    listen                  80;
    server_name             example.com;
    root                    /usr/share/nginx/html;
}

我的博客位于./volumes/blog/public/下。这是由Hexo生成的网站。

https://example.com返回加载错误页面。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我正在使用基于https://tevinjeffrey.me/how-to-setup-nginx-proxy-and-lets-encrypt-with-docker/的设置,我在下面粘贴。此外,请确保您拥有针对运行堆栈的框的example.com的有效DNS记录。

version: '2'

services:

  nginx:
    build:
      context: ./docker/nginx/
      dockerfile: Dockerfile
    volumes_from:
      - php
    environment:
      VIRTUAL_HOST: www.example.com.ar
      LETSENCRYPT_HOST: www.example.com.ar
      LETSENCRYPT_EMAIL: info@example.com.ar

  php:
    build: ./docker/php/
    expose:
        - 9000
    volumes:
        - ./docker/data/html/:/var/www/html

  nginx-proxy:
    image: jwilder/nginx-proxy
    ports:
        - "80:80"
        - "443:443"
    volumes:
        - "/etc/nginx/vhost.d"
        - "/usr/share/nginx/html"
        - "/var/run/docker.sock:/tmp/docker.sock:ro"
        - "/etc/nginx/certs"

  letsencrypt-nginx-proxy-companion:
    image: jrcs/letsencrypt-nginx-proxy-companion
    volumes:
        - "/var/run/docker.sock:/var/run/docker.sock:ro"
    volumes_from:
        - "nginx-proxy"