我用以下撰写文件创建了一个Docker Swarm:
version: '3.5'
services:
traefik:
image: traefik:v1.7.12
deploy:
replicas: 1
placement:
constraints: [ node.role == manager ]
networks:
- frontend
ports:
- "80:80"
- "443:443"
- "8081:8080"
volumes:
- ./traefik.toml:/etc/traefik/traefik.toml
- ./access.log:/var/log/access.log
- ./acme.json:/etc/traefik/acme.json
- ./traefik.log:/var/log/traefik.log
- /var/run/docker.sock:/var/run/docker.sock
test:
image: emilevauge/whoami
deploy:
labels:
- "traefik.frontend.rule=Host:myserver;Path:/test"
- "traefik.port=80"
networks:
- frontend
networks:
frontend:
name: "frontend"
driver: overlay
这是我的traefik.toml
文件:
defaultEntryPoints = [ "http" ]
[traefikLog]
filePath = "/var/log/traefik.log"
[accessLog]
filePath = "/var/log/access.log"
[accessLog.fields]
defaultMode = "keep"
[accessLog.fields.names]
"FrontendName" = "keep"
"BackendName" = "keep"
[entryPoints]
[entryPoints.dashboard]
address = ":8080"
[entryPoints.http]
address = ":80"
[api]
entrypoint = "dashboard"
debug = true
dashboard = true
[api.statistics]
[ping]
entrypoint = "http"
[docker]
watch = true
swarmMode = true
endpoint = "unix:///var/run/docker.sock"
network = "frontend"
我已经在Digital Ocean的一个小滴上部署了这种配置的集群,并发现它可以正常工作。但是,我需要在工作场所中部署到Ubuntu虚拟服务器,这就是我遇到的问题。服务器位于外部负载均衡器后面。当我将此群部署到我的工作服务器时,我无法连接到whoami
(端口80)服务器或traefik
仪表板(端口8081)。我的浏览器显示ERR_CONNECTION_RESET
和“无法访问此站点”。
我已在我公司的技术支持下验证端口是否打开。另外,如果我在工作服务器上启动以下traefik
-less的配置,则whoami
服务将按预期工作:
version: '3.5'
services:
test:
image: emilevauge/whoami
networks:
- frontend
ports:
- "80:80" # works with 8081:80 too
networks:
frontend:
name: "frontend"
driver: overlay
最后,我检查了access.log
文件,但找不到我的网络浏览器的任何访问记录。唯一的访问权限似乎是每秒更新一次:
10.255.0.2 - - [06/Aug/2019:13:19:23 +0000] "GET / HTTP/1.1" 404 19 "-" "a10hm/1.0" 245 "backend not found" "/" 0ms
10.255.0.2 - - [06/Aug/2019:13:19:24 +0000] "GET / HTTP/1.1" 404 19 "-" "a10hm/1.0" 246 "backend not found" "/" 0ms
10.255.0.2 - - [06/Aug/2019:13:19:28 +0000] "GET / HTTP/1.1" 404 19 "-" "a10hm/1.0" 247 "backend not found" "/" 0ms
10.255.0.2 - - [06/Aug/2019:13:19:29 +0000] "GET / HTTP/1.1" 404 19 "-" "a10hm/1.0" 248 "backend not found" "/" 0ms
10.255.0.2 - - [06/Aug/2019:13:19:34 +0000] "GET / HTTP/1.1" 404 19 "-" "a10hm/1.0" 249 "backend not found" "/" 0ms
10.255.0.2 - - [06/Aug/2019:13:19:34 +0000] "GET / HTTP/1.1" 404 19 "-" "a10hm/1.0" 250 "backend not found" "/" 0ms
10.255.0.2 - - [06/Aug/2019:13:19:39 +0000] "GET / HTTP/1.1" 404 19 "-" "a10hm/1.0" 251 "backend not found" "/" 0ms
10.255.0.2 - - [06/Aug/2019:13:19:39 +0000] "GET / HTTP/1.1" 404 19 "-" "a10hm/1.0" 252 "backend not found" "/" 0ms
我应该检查些什么以找出为什么我的http请求似乎没有达到traefik
?是我公司的外部负载平衡器引起问题还是traefik
出了问题?