Traefik:通过本地 IP 地址以及外部 (https) 访问服务?
Traefik: Access service via local IP address as well as externally (https)?
我设法用我的域 (https://MY-DOMAIN.COM), and I think I read that it's also possible to access the service on my local network (http://192.168.0.5:8123 or http://my-server.local:8123) 设置了反向代理,而不仅仅是通过 https 在外部设置。
有人知道这是不是真的,如果是的话我该如何设置?
这是我的 docker-compose.yml 代码:
version: '3'
networks:
proxy:
external: true
services:
reverse-proxy:
container_name: ReverseProxy
image: traefik
restart: always
command: --web --docker
ports:
- 8080:8080
- 80:80
- 443:443
networks:
- proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ~/docker/traefik/traefik.toml:/traefik.toml
- ~/docker/traefik/acme.json:/acme.json
homeassistant:
image: homeassistant/home-assistant
container_name: home-assistant
restart: unless-stopped
networks:
- proxy
expose:
- 8123
volumes:
- ~/docker/homeassistant:/config
- /etc/localtime:/etc/localtime:ro
labels:
- "traefik.backend=home-assistant"
- "traefik.docker.network=proxy"
- "traefik.frontend.rule=Host:MY-DOMAIN.COM"
- "traefik.enable=true"
- "traefik.port=8123"
- "traefik.default.protocol=http"
这是我的 traefik.toml 代码:
debug = false
logLevel = "ERROR"
defaultEntryPoints = ["https","http"]
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[retry]
[web]
address = ":8080"
[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "MY-DOMAIN.COM"
watch = true
exposedbydefault = false
[acme]
email = "MY-EMAIL-ADDRESS"
storage = "acme.json"
entryPoint = "https"
OnHostRule = true
[acme.httpChallenge]
entryPoint = "http"
[[acme.domains]]
main = "MY-DOMAIN.COM"
在您的 homeassistant docker-compose 配置中更改以下内容以允许您的主机将 8123 映射到容器。
来自:
expose:
- 8123
至:
ports:
- "8123:8123"
来源:What is the difference between docker-compose ports vs expose
我设法用我的域 (https://MY-DOMAIN.COM), and I think I read that it's also possible to access the service on my local network (http://192.168.0.5:8123 or http://my-server.local:8123) 设置了反向代理,而不仅仅是通过 https 在外部设置。
有人知道这是不是真的,如果是的话我该如何设置?
这是我的 docker-compose.yml 代码:
version: '3'
networks:
proxy:
external: true
services:
reverse-proxy:
container_name: ReverseProxy
image: traefik
restart: always
command: --web --docker
ports:
- 8080:8080
- 80:80
- 443:443
networks:
- proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ~/docker/traefik/traefik.toml:/traefik.toml
- ~/docker/traefik/acme.json:/acme.json
homeassistant:
image: homeassistant/home-assistant
container_name: home-assistant
restart: unless-stopped
networks:
- proxy
expose:
- 8123
volumes:
- ~/docker/homeassistant:/config
- /etc/localtime:/etc/localtime:ro
labels:
- "traefik.backend=home-assistant"
- "traefik.docker.network=proxy"
- "traefik.frontend.rule=Host:MY-DOMAIN.COM"
- "traefik.enable=true"
- "traefik.port=8123"
- "traefik.default.protocol=http"
这是我的 traefik.toml 代码:
debug = false
logLevel = "ERROR"
defaultEntryPoints = ["https","http"]
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[retry]
[web]
address = ":8080"
[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "MY-DOMAIN.COM"
watch = true
exposedbydefault = false
[acme]
email = "MY-EMAIL-ADDRESS"
storage = "acme.json"
entryPoint = "https"
OnHostRule = true
[acme.httpChallenge]
entryPoint = "http"
[[acme.domains]]
main = "MY-DOMAIN.COM"
在您的 homeassistant docker-compose 配置中更改以下内容以允许您的主机将 8123 映射到容器。
来自:
expose:
- 8123
至:
ports:
- "8123:8123"
来源:What is the difference between docker-compose ports vs expose