Skip to content

Commit c6a784c

Browse files
committed
Normalize caddy-home-assistant-liar
docker-compose.yml: - Rename service caddy -> caddy-home-assistant-liar (matches container_name) - Use ${IMAGE_VERSION:-latest} for image tag - Uncomment hass network (required for reverse_proxy home-assistant:8123) - Rename network alias home-assistant -> hass (project convention) - Add env_file config/Caddyfile.default (renamed from Caddyfile.example): - Renamed so configure_app can auto-copy it to Caddyfile on install Add .env.example, README.md, .rsync-exclude Made-with: Cursor
1 parent ef27fe3 commit c6a784c

5 files changed

Lines changed: 133 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Image version (optional, defaults to latest)
2+
#IMAGE_VERSION=latest

apps/caddy-home-assistant-liar/.rsync-exclude

Whitespace-only changes.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# caddy-home-assistant-liar
2+
3+
A Caddy reverse proxy that spoofs `X-Forwarded-For` and `X-Real-IP` headers to
4+
make Home Assistant believe incoming requests originate from a trusted local IP
5+
address. This bypasses Home Assistant's IP-based authentication check when
6+
requests arrive via nginx-proxy-manager from a non-RFC1918 source.
7+
8+
## How it works
9+
10+
nginx-proxy-manager → **caddy-home-assistant-liar** → home-assistant
11+
12+
Caddy rewrites the forwarded IP headers to `192.168.0.0` before passing
13+
requests upstream to `home-assistant:8123`. Home Assistant sees a local IP
14+
and grants access without requiring authentication.
15+
16+
## Configuration
17+
18+
### Caddyfile
19+
20+
Copy the default config and edit as needed:
21+
22+
```bash
23+
cp config/Caddyfile.default config/Caddyfile
24+
```
25+
26+
Key settings in `config/Caddyfile`:
27+
28+
| Setting | Description |
29+
|---------|-------------|
30+
| `trusted_proxies static <IP>` | IP of the nginx-proxy-manager container on the caddy network — check with `docker inspect` if it changes |
31+
| `X-Forwarded-For` / `X-Real-IP` | Spoofed local IP sent to Home Assistant |
32+
| `reverse_proxy home-assistant:8123` | Upstream Home Assistant container (resolved via hass-net) |
33+
34+
### Environment Variables
35+
36+
No required environment variables. Optionally set `IMAGE_VERSION` in `.env`
37+
to pin the Caddy image tag.
38+
39+
## Network dependencies
40+
41+
| Network | Provided by | Purpose |
42+
|---------|-------------|---------|
43+
| `nginx-proxy-net` | nginx-proxy-manager | Receives inbound requests from the reverse proxy |
44+
| `hass-net` | home-assistant | Reaches `home-assistant:8123` by container name |
45+
| `caddy-home-assistant-liar-net` | this service | Internal network created by this service |
46+
47+
## Usage
48+
49+
### Starting the service
50+
51+
```bash
52+
# Configure Caddyfile first
53+
cp config/Caddyfile.default config/Caddyfile
54+
# Edit config/Caddyfile if needed, then:
55+
docker compose up -d
56+
```
57+
58+
### Stopping the service
59+
60+
```bash
61+
docker compose down
62+
```
63+
64+
### Viewing logs
65+
66+
```bash
67+
docker compose logs -f
68+
```
69+
70+
### Reloading Caddy config without restart
71+
72+
```bash
73+
docker compose exec caddy-home-assistant-liar caddy reload --config /etc/caddy/Caddyfile
74+
```
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
servers {
3+
trusted_proxies static 172.18.0.17 # The IP nc showed as the source
4+
}
5+
}
6+
7+
http://ctrlh:8888, :8888 {
8+
request_header X-Forwarded-For "192.168.0.0"
9+
request_header X-Real-IP "192.168.0.0"
10+
11+
reverse_proxy home-assistant:8123 {
12+
# for debugging - to see headers run: nc -v -l -p 8089
13+
# reverse_proxy 192.168.13.2:8089 {
14+
# Force removal of existing headers
15+
# (don't actually do this, this removes the headers we add as well)
16+
# header_up -X-Forwarded-For
17+
# header_up -X-Real-IP
18+
19+
# 2. Use the '+' prefix to FORCE add these headers
20+
header_up X-Forwarded-For "192.168.0.0"
21+
header_up X-Real-IP "192.168.0.0"
22+
23+
24+
# 3. Add a canary header to prove Caddy is reading this block
25+
header_up +X-Spoof-Active "True"
26+
27+
header_up X-Forwarded-Proto {scheme}
28+
}
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
services:
2+
caddy-home-assistant-liar:
3+
image: caddy:${IMAGE_VERSION:-latest}
4+
container_name: caddy-home-assistant-liar
5+
hostname: caddy-home-assistant-liar
6+
restart: unless-stopped
7+
# ports:
8+
# - 80:80
9+
volumes:
10+
- ./config:/etc/caddy
11+
- ../../lib/caddy-home-assistant-liar/data:/data
12+
- ../../lib/caddy-home-assistant-liar/config:/config
13+
env_file:
14+
- .env
15+
networks:
16+
- proxy
17+
- hass
18+
- caddy
19+
20+
networks:
21+
proxy:
22+
external: true
23+
name: nginx-proxy-net
24+
hass:
25+
external: true
26+
name: hass-net
27+
caddy:
28+
name: caddy-home-assistant-liar-net

0 commit comments

Comments
 (0)