Unverified Commit e9a56d04 authored by Tom Moulard's avatar Tom Moulard Committed by GitHub
Browse files

fix: improve default configuration for homeassistant (#45)

parent 2bed8019
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -6,6 +6,11 @@ Open source home automation that puts local control and privacy first. Powered
by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a
Raspberry Pi or a local server.

Note that traefik's basic auth cannot be used with home assistant, as
[HA does not support](https://github.com/home-assistant/iOS/issues/193#issuecomment-760662881)
using the `Authorization` header for anything else than HA.


## configuration

To enable [prometheus metrics](https://www.home-assistant.io/integrations/prometheus/),
@@ -14,3 +19,20 @@ add the following to your `configuration.yaml`:
```yaml
prometheus:
```

You can also [configure basic informations](https://www.home-assistant.io/docs/configuration/basic/)
about your home assistant instance by setting the `homeassistant` key in your
`configuration.yaml`. It is the recommended way to configure your instance as
is is not possible to secure the instance with traefik's basic auth.

Here is how to tell HA that it is [behind](https://www.home-assistant.io/integrations/http/#reverse-proxies)
a reverse proxy:

```yaml
http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 127.0.0.1   # localhost
    - ::1         # localhost but in IPv6
    - 172.0.0.0/8 # docker network
```
+1 −2
Original line number Diff line number Diff line
@@ -12,9 +12,8 @@ services:
      test: ['CMD', 'curl', '0.0.0.0:8123']
    labels:
      traefik.enable: true
      traefik.http.routers.homeassistant.middlewares: 'basic_auth@docker'
      traefik.http.routers.homeassistant.rule: |
        'Host(`homeassistant.${SITE:-localhost}`) && !Path(`/api/prometheus`)'
        Host(`homeassistant.${SITE:-localhost}`) && !Path(`/api/prometheus`)
      traefik.http.services.homeassistant.loadbalancer.server.port: 8123
    # network_mode: host # might be required to discover som devices(i.e.,UPnP).
    networks:
+1 −2
Original line number Diff line number Diff line
@@ -433,9 +433,8 @@ services:
    image: ghcr.io/home-assistant/home-assistant:stable
    labels:
      traefik.enable: "true"
      traefik.http.routers.homeassistant.middlewares: basic_auth@docker
      traefik.http.routers.homeassistant.rule: |
        'Host(`homeassistant.localhost`) && !Path(`/api/prometheus`)'
        Host(`homeassistant.localhost`) && !Path(`/api/prometheus`)
      traefik.http.services.homeassistant.loadbalancer.server.port: "8123"
    networks:
      srv: null