我看了几本指南,终于可以使它工作了,但我真的不知道为什么。
这是工作设置:
version: '3'
networks:
proxy:
external: true
internal:
services:
traefik:
image: traefik # The official Traefik docker image
restart: unless-stopped
command: --api --docker # Enables the web UI and tells Traefik to listen to docker
ports:
- "8443:8443" # The HTTPS port
- "80:80" # The HTTP port
volumes:
- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
- ~/docker/traefik:/etc/traefik/ #toml, certificates
container_name: traefik
labels:
- traefik.frontend.rule=Host:monitor.example.com
- traefik.port=8080
networks:
- proxy
nextcloud:
image: wonderfall/nextcloud
restart: unless-stopped
depends_on:
- nextcloud-db # If using MySQL
environment:
- UID=911
- GID=911
- UPLOAD_MAX_SIZE=10G
- APC_SHM_SIZE=128M
- OPCACHE_MEM_SIZE=128
- CRON_PERIOD=15m
- TZ=Asia/Shanghai
# - ADMIN_USER=admin # Don't set to configure through browser
# - ADMIN_PASSWORD=admin # Don't set to configure through browser
- DOMAIN=localhost
- DB_TYPE=mysql
- DB_NAME=nextcloud
- DB_USER=nextcloud
- DB_PASSWORD=supersecretpassword
- DB_HOST=nextcloud-db
labels:
- traefik.port=8888
- traefik.backend=nextcloud
- traefik.frontend.rule=Host:nextcloud.example.com
- traefik.frontend.entryPoints=http,https
- traefik.enable=true
- traefik.docker.network=proxy
volumes:
- /ndisk1/nextcloud:/var/www/html
- /ndisk1/media:/media
ports:
- 8888:8888
networks:
- internal
- proxy
此设置使用命令创建的外部网络:
docker network create proxy
但是,如果我让docker组成网络代理,
networks:
proxy:
external: false
internal:
它可以访问monitor.example.com,但在访问nextcloud.example.com时会超时。
有什么主意吗?