Add an nginx version of the /heos proxy
Same contract as the Apache one -- strip the prefix off the request, tell the app about it with X-Forwarded-Prefix, keep it to the local network -- with the two things nginx needs that Apache did not: a redirect for the bare /heos, which would otherwise miss the location and fall through to the filesystem, and the trailing slash on proxy_pass that does the stripping. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -104,9 +104,9 @@ WantedBy=multi-user.target
|
||||
sudo systemctl enable --now heos-panel
|
||||
```
|
||||
|
||||
## Behind Apache, at /heos
|
||||
## Behind a reverse proxy, at /heos
|
||||
|
||||
`deploy/heos.conf` reverse-proxies `/heos` to the panel:
|
||||
`deploy/heos.conf` reverse-proxies `/heos` to the panel with Apache:
|
||||
|
||||
```bash
|
||||
sudo a2enmod proxy proxy_http headers
|
||||
@@ -115,11 +115,16 @@ sudo a2enconf heos
|
||||
sudo apachectl configtest && sudo systemctl reload apache2
|
||||
```
|
||||
|
||||
It ships restricted to the local network — it controls the speakers, and
|
||||
it usually hangs off a vhost with a public certificate. Delete the
|
||||
`RequireAny` block to open it up.
|
||||
`deploy/heos.nginx.conf` is the same thing for nginx: copy it to
|
||||
`/etc/nginx/snippets/heos.conf`, `include snippets/heos.conf;` inside the
|
||||
`server` block, then `sudo nginx -t && sudo systemctl reload nginx`.
|
||||
|
||||
The app works at either address without being told which. Apache sends
|
||||
Both ship restricted to the local network — this controls the speakers, and
|
||||
it usually hangs off a host with a public certificate. Delete the
|
||||
`RequireAny` block (Apache) or the `allow`/`deny` lines (nginx) to open it
|
||||
up.
|
||||
|
||||
The app works at either address without being told which. The proxy sends
|
||||
`X-Forwarded-Prefix: /heos`, and every URL the app generates — stylesheet,
|
||||
icons, the manifest's `start_url`, every `fetch` — picks up that prefix.
|
||||
Serve it straight from port 5005 and the same URLs come out as `/...`.
|
||||
@@ -128,8 +133,8 @@ and nothing on it works.
|
||||
|
||||
Two things worth knowing:
|
||||
|
||||
- The `<Location>` block takes `/heos` away from the filesystem, so the
|
||||
source under `/var/www/html/heos` stops being served as static files.
|
||||
- The proxy block takes `/heos` away from the filesystem, so the source
|
||||
under `/var/www/html/heos` stops being served as static files.
|
||||
- The panel still answers directly on `<pi-ip>:5005`. Start it with
|
||||
`--host 127.0.0.1` if you want Apache to be the only way in.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user