我从Google Domains购买了一个域名。我将DNS记录更改为cloudflare。然后,我制作了一个.htpasswd
文件并将其保存到/docker/shared/
,我还制作了一个rules.toml
文件,该文件位于/etc/traefik/rules.toml
上,没有在文件中放置任何内容。
我有一个文件位于/docker/traefik/traefik.toml
,该文件中包含以下内容(我将EMAIL和DOMAIN更改为我的):
#debug = true
logLevel = "ERROR" #DEBUG, INFO, WARN, ERROR, FATAL, PANIC
InsecureSkipVerify = true
defaultEntryPoints = ["https", "http"]
# WEB interface of Traefik - it will show web page with overview of frontend and backend configurations
[web]
address = ":8080"
[web.auth.basic]
usersFile = "/shared/.htpasswd"
# Force HTTPS
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[file]
watch = true
filename = "/etc/traefik/rules.toml"
# Let's encrypt configuration
[acme]
email = "email@domain.com" #any email id will work
storage="/etc/traefik/acme/acme.json"
entryPoint = "https"
acmeLogging=true
onDemand = false #create certificate when container is created
[acme.dnsChallenge]
provider = "cloudflare"
delayBeforeCheck = 0
[[acme.domains]]
main = "EXAMPLE.COM"
[[acme.domains]]
main = "*.EXAMPLE.COM"
# Connection to docker host system (docker.sock)
[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "EXAMPLE.COM"
watch = true
# This will hide all docker containers that don't have explicitly
# set label to "enable"
exposedbydefault = false
这是我的docker-compose文件:
version: "3.6"
services:
portainer:
image: portainer/portainer
container_name: portainer
restart: always
command: --templates http://templates/templates.json
ports:
- "9000:9000"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${USERDIR}/docker/portainer/data:/data
- ${USERDIR}/docker/shared:/shared
environment:
- TZ=${TZ}
watchtower:
container_name: watchtower
restart: always
image: v2tec/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: --schedule "0 0 4 * * *" --cleanup
netdata:
container_name: vigilant_aryabhata
restart: always
image: titpetric/netdata
ports:
- "19999:19999"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- TZ=${TZ}
traefik:
hostname: traefik
image: traefik:latest
container_name: traefik
restart: always
domainname: ${DOMAINNAME}
networks:
# - default
- traefik_proxy
ports:
- "80:80"
- "443:443"
# - "8080:8080"
environment:
- CLOUDFLARE_EMAIL=${CLOUDFLARE_EMAIL}
- CLOUDFLARE_API_KEY=${CLOUDFLARE_API_KEY}
labels:
- "traefik.enable=true"
- "traefik.backend=traefik"
# - "traefik.frontend.rule=Host:traefik.${DOMAINNAME}"
- "traefik.frontend.rule=Host:${DOMAINNAME}; PathPrefixStrip: /traefik"
- "traefik.port=8080"
- "traefik.docker.network=traefik_proxy"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${USERDIR}/docker/traefik:/etc/traefik
- ${USERDIR}/docker/shared:/shared
networks:
traefik_proxy:
external:
name: traefik_proxy
default:
driver: bridge
然后我运行:
docker-compose -f ${USERDIR}/docker/docker-compose.yml up -d
然后我运行:
steve@TeamAmerica-PlexServer:~/docker$ docker-compose logs -tf --tail="50"
然后给我以下错误:
traefikAttaching to traefik
traefik | 2018-07-08T01:15:14.506938691Z time="2018-07-08T01:15:14Z" level=error msg="Error starting provider *file.Provider: error reading configuration file: /etc/traefik/rules.toml - open /etc/traefik/rules.toml: no such file or directory"
从这里我真的不知道该怎么办。
答案 0 :(得分:0)
我还制作了一个位于/etc/traefik/rules.toml的rules.toml文件。在此文件中没有放置任何内容。
在您的配置中,您列出:
[file]
watch = true
filename = "/etc/traefik/rules.toml"
这是您计算机上的${USERDIR}/docker/traefik
吗?这样容器才能访问它?