0

我需要托管多个域,所以我关注了这个博客: https : //www.datanovia.com/en/lessons/how-host-multiple-https-websites-on-one-server/ 为我的 nginx 配置了以下配置-代理人:

version: '3'

services:
  nginx:
    image: nginx:1.13.1
    container_name: nginx-proxy
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - conf:/etc/nginx/conf.d
      - vhost:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html
      - certs:/etc/nginx/certs
    labels:
      - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"

  dockergen:
    image: jwilder/docker-gen:0.7.3
    container_name: nginx-proxy-gen
    depends_on:
      - nginx
    command: -notify-sighup nginx-proxy -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
    volumes:
      - conf:/etc/nginx/conf.d
      - vhost:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html
      - certs:/etc/nginx/certs
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro
  
  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: nginx-proxy-le
    depends_on:
      - nginx
      - dockergen
    environment:
      NGINX_PROXY_CONTAINER: nginx-proxy
      NGINX_DOCKER_GEN_CONTAINER: nginx-proxy-gen
    volumes:
      - conf:/etc/nginx/conf.d
      - vhost:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html
      - certs:/etc/nginx/certs
      - /var/run/docker.sock:/var/run/docker.sock:ro

volumes:
  conf:
  vhost:
  html:
  certs:

# Do not forget to 'docker network create nginx-proxy' before launch, and to add '--network nginx-proxy' to proxyed containers. 

networks:
  default:
    external:
      name: nginx-proxy

对于我的 Wordpress,我有:

version: "3"

services:
  wp_db:
    image: mysql:8.0
    restart: always
    env_file: .env
    environment:
      - MYSQL_DATABASE=wordpress
    container_name: wp_db
    volumes: 
      - dbdata:/var/lib/mysql
      - "./backups/db:/backups"
      - "./config:/config"
    command: '--default-authentication-plugin=mysql_native_password'


  example_domain_wp:
    container_name: example_domain_wp
    depends_on:
      - wp_db
    image: wordpress:latest
    expose:
      - 80
    restart: always
    environment:
      VIRTUAL_HOST: example.com 
      VIRTUAL_PORT: 80
      LETSENCRYPT_HOST: example.com
      LETSENCRYPT_EMAIL: some.email@gmail.com
      WORDPRESS_DB_HOST : wp_db:3306
      WORDPRESS_DB_USER : $MYSQL_USER
      WORDPRESS_DB_PASSWORD : $MYSQL_PASSWORD
      WORDPRESS_DB_NAME : wordpress
      WORDPRESS_CONFIG_EXTRA: |
        define('WP_DEBUG', false);
        define('WP_DEBUG_DISPLAY', false);
    volumes:
      - ./php/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
      - ./wp-content:/var/www/html/wp-content
volumes:
  dbdata:

networks:
  default:
    external:
      name: nginx-proxy

当我使用 docker-compose 运行服务时,我得到:

Verify error:Invalid response from https://example.com/.well-known/acme-challenge/SOME_ID

我在 Ubuntu 18 LTS 上运行 docker。

知道如何解决吗?

非常感谢。

4

0 回答 0