我设法用我的域(https://MY-DOMAIN.COM(设置了一个反向代理,我想我读到也可以在我的本地网络(http://192.168.0.5:8123 或 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"
在家庭助理 docker-compose 配置上,更改以下内容以允许主机将 8123 映射到容器。
从:
expose:
- 8123
自:
ports:
- "8123:8123"
来源:docker-compose ports 与 expose 有什么区别