1
首先,如果我沒有使用正確的術語來問這個問題,我很抱歉,但我沒有達到專業術語。如何讓traefik重定向到Docker內部的特定非碼頭端口
我有一個在Docker容器中運行的traefik,並使用PathPrefix選項提供一些服務,例如,www.myserver.com/wordpress重定向到運行wordpress的docker容器。
但是,如何讓它重定向到碼頭集裝箱外?具體來說,我如何讓www.myserver.com重定向到我的機器中的端口8080,以便爲我在主機操作系統(不是在碼頭集裝箱中)運行的服務提供服務?
這是我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 = "[email protected]"
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