Merge pull request 'homeassistant' (#2) from homeassistant into main

Reviewed-on: #2
This commit is contained in:
kevinheyer 2025-03-16 21:54:13 +00:00
commit 069e21adbd
3 changed files with 102 additions and 0 deletions

View file

@ -0,0 +1,5 @@
# Homeassistant Version (Standard: latest)
HOMEASSISTANT_VERSION=latest
# Homeassistant Domain
HOMEASSISTANT_DOMAIN=homeassistant.example.com

62
homeassistant/README.md Normal file
View file

@ -0,0 +1,62 @@
# Home Assistant Docker Setup with Traefik
This guide provides instructions for deploying Home Assistant using Docker and Traefik as a reverse proxy. The setup includes securing the Home Assistant instance with HTTPS and configuring a trusted proxy.
## Prerequisites
- Docker and Docker Compose installed on your system
- Traefik configured as your reverse proxy
- A domain name pointing to your Home Assistant instance
## Environment Variables
Before deploying the container, create a `.env` file from the provided `.env-example` file and adjust the values as needed.
```sh
cp .env-example .env
nano .env
```
### `.env-example` file
```ini
# Home Assistant Version (Default: latest)
HOMEASSISTANT_VERSION=latest
# Home Assistant Domain
HOMEASSISTANT_DOMAIN=homeassistant.example.com
```
## Starting the Container
Once the `.env` file is configured, start the Home Assistant container using:
```sh
docker-compose up -d
```
## Configuring the Reverse Proxy
To enable proper proxy support in Home Assistant, update `data/config/configuration.yaml` with the following settings:
### Finding the Local Subnet IP
To determine the Docker subnet used by Home Assistant, run:
```sh
docker inspect homeassistant | grep Gateway
```
### `configuration.yaml`
```yaml
http:
ip_ban_enabled: true
login_attempts_threshold: 5
use_x_forwarded_for: true
trusted_proxies:
- 10.0.0.0/24 # Local Subnet
- 172.18.0.0/24 # Your Docker Subnet
```
## Accessing Home Assistant
Once everything is set up, restart Home Assistant and it should be accessible via the configured domain:
```
https://homeassistant.example.com
```
If there are any issues, check the container logs with:
```sh
docker logs -f homeassistant
```

View file

@ -0,0 +1,35 @@
---
services:
homeassistant:
container_name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:${HOMEASSISTANT_VERSION:-latest}"
volumes:
- ./data/config:/config
- /etc/localtime:/etc/localtime:ro
- /run/dbus:/run/dbus:ro
restart: unless-stopped
privileged: true
networks:
- traefik
environment:
- TZ=Europe/Rome
cap_add:
- NET_ADMIN
- NET_BIND_SERVICE
- SYS_ADMIN
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik"
- "traefik.http.routers.homeassistant.entrypoints=http"
- "traefik.http.routers.homeassistant.rule=Host(`${HOMEASSISTANT_DOMAIN:?error}`)"
- "traefik.http.middlewares.homeassistant-https-redirect.redirectscheme.scheme=https"
- "traefik.http.routers.homeassistant.middlewares=homeassistant-https-redirect"
- "traefik.http.routers.homeassistant-secure.entrypoints=https"
- "traefik.http.routers.homeassistant-secure.rule=Host(`${HOMEASSISTANT_DOMAIN:?error}`)"
- "traefik.http.routers.homeassistant-secure.tls=true"
- "traefik.http.routers.homeassistant-secure.service=homeassistant"
- "traefik.http.services.homeassistant.loadbalancer.server.port=8123"
networks:
traefik:
external: true