首先,如果我没有使用正确的术语来提出这个问题,我很抱歉,但我不符合现有的术语。
我在 docker 容器中运行 traefik,并使用 PathPrefix 选项提供一些服务,例如,www.myserver.com/wordpress 重定向到运行 wordpress 的 docker 容器。
但是如何让它重定向到 docker 容器之外呢?具体来说,我如何让 www.myserver.com 重定向到我机器中的端口 8080 以提供我在主机操作系统中运行的服务(而不是在 docker 容器中)?
这是我的traefik.toml
:
logLevel = "DEBUG"
defaultEntryPoints = ["http", "https"]
[entryPoints]
[entryPoints.http]
address = ":80"
compress = false
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[acme]
email = "mymail@mail.com"
storage = "acme.json"
entryPoint = "https"
onHostRule = true
#onDemand = true
[[acme.domains]]
main = "www.myserver.com"
[web]
address = ":8888"
[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "www.myserver.com"
watch = true
exposedbydefault = false
我docker-compose.yml
的 traefik 容器:
version: "2"
services:
traefik:
image: traefik
network_mode: "host"
ports:
- "80:80"
- "443:443"
- "8888:8888"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${SERVER_DIR}/AppData/traefik:/etc/traefik/
- ${PWD}/acme.json:/acme.json
- ${PWD}/traefik.toml:/etc/traefik/traefik.toml
- ${PWD}/servers.toml:/etc/traefik/servers.toml
restart: never