2

I managed to setup a reverse proxy with my domain (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), not just externally via https.

Anyone know if this is true, and if so how I'd set that up?

Here's my docker-compose.yml code:

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"


And here's my traefik.toml code:

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"
namokarm
  • 668
  • 1
  • 7
  • 20
Jono Hunt
  • 23
  • 1
  • 4

1 Answers1

0

On your homeassistant docker-compose config change the following to allow your host to map 8123 to the container.

from:

expose:
  - 8123

to:

ports:
  - "8123:8123"

source: What is the difference between docker-compose ports vs expose

  • You don't want to map static ports. First you don't want them to be accessible and second you can scale as the replica will fail due to occupied port on the host. The whole point of traefik is to do service discovery meaning using dynamic ports. – The Fool Oct 30 '20 at 17:28