我尝试在版本2中设置Traefik,但我的浏览器中只出现“404 Page not found”或DNS_PROBE_FINISHED_NXDOMAIN
错误。
当我检查路由器的API端点时,我可以看到我的两个容器在Traefik中被启用,并且规则是正确的。
curl http://localhost:8080/api/http/routers
[{"entryPoints":["web","secure"],"service":"gotify-gotify","rule":"Host(`sub2.example.org`)","tls":{"certResolver":"letsencrypt"},"status":"enabled","using":["secure","web"],"name":"gotify@docker","provider":"docker"},{"entryPoints":["web","secure"],"service":"nextcloud-cloud","rule":"Host(`sub.example.org`)","tls":{"certResolver":"letsencrypt"},"status":"enabled","using":["secure","web"],"name":"nextcloud@docker","provider":"docker"}]
但是在“sub2”上我根本没有得到任何网站,在“sub”上我得到“404页面找不到”。我已经为“*”设置了一个DNS条目,所以所有子域都到同一个服务器。
我为Docker集装箱设置了以下标签
labels:
traefik.enable: true
traefik.http.routers.nextcloud.rule: "Host(`sub.example.org`)"
traefik.http.routers.nextcloud.entrypoints: "web, secure"
traefik.http.routers.nextcloud.tls.certresolver: "letsencrypt"
这是我的Traefik配置traefik.tom
l
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.secure]
address = ":443"
[providers.docker]
exposedByDefault = false
network = "traefik"
[certificatesResolvers.letsencrypt.acme]
email = "me@example.org"
storage = "acme.json"
[certificatesResolvers.letsencrypt.acme.httpChallenge]
entryPoint = "web"
[api]
insecure = true
debug = true
dashboard = false
Traefik本身是作为码头集装箱运行的。
version: "3.7"
services:
traefik:
image: traefik:v2.0
container_name: traefik
restart: unless-stopped
volumes:
- "./traefik.toml:/etc/traefik/traefik.toml"
- "./acme:/etc/traefik/acme"
- "/var/run/docker.sock:/var/run/docker.sock"
ports:
- "80:80"
- "127.0.0.1:8080:8080"
- "443:443"
networks:
- traefik
networks:
traefik:
driver: bridge
name: traefik
我使用ufw
来管理防火墙规则,并打开了端口22、80和443
Status: active
To Action From
-- ------ ----
22/tcp ALLOW Anywhere
80/tcp ALLOW Anywhere
443/tcp ALLOW Anywhere
22/tcp (v6) ALLOW Anywhere (v6)
80/tcp (v6) ALLOW Anywhere (v6)
443/tcp (v6) ALLOW Anywhere (v6)
2条答案
按热度按时间egmofgnx1#
您可以找到traefik 2.2.1的工作示例。此外,您还可以查看完整的设置要点:https://gist.github.com/fatihyildizhan/8f124039a9bd3801f0caf3c01c3601fb
我更喜欢使用2.0版本的traefik.yml。它看起来很简单,很多人都熟悉YAML文件。
mtb9vblg2#
有几个原因可能导致这种情况,其中包括:
1.您在DNS级别启用了SSL/TLS代理(例如CloudFlare),这将阻止http质询完成。
1.证书解析程序的存储路径配置错误(可能不是在这种情况下,而是对其他读取器);检查Traefik container日志
docker logs traefik
中是否存在等错误如果您看到这些错误,请确保存储文件夹存在和/或卷已从您的主机正确Map到Traefik docker container(您可能需要手动创建,Traefik不会为您创建,至少目前不会)。
1.代理背后的服务存在技术问题(例如,Nginx、Apache等配置错误)。Traefik将为一系列在技术上与真实的的404错误不对应的错误(例如,500、501,可能是其他错误)生成通用的
404 page not found
,这可能会引起混淆。