Add instructions on how to reverse proxy

This commit is contained in:
Nexus 2024-02-25 22:17:21 +00:00
parent be73449353
commit 69de1606d1
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -27,6 +27,29 @@ pip install -r requirements.txt
PREVIEW_HOMESERVER=https://example.com python3 server.py PREVIEW_HOMESERVER=https://example.com python3 server.py
``` ```
### With a reverse proxy
You should use a reverse proxy to handle routing the request to this server. An example with caddy
(ripped from my config file for matrix.nexy7574.co.uk)is below:
```caddy
matrix.example.com {
# Add cache control, CSP, and CORP:
header /_matrix/media/*/thumbnail/*/* Cache-Control 'max-age=172800,stale-while-revalidate=86400'
header /_matrix/media/*/download/*/* Cache-Control 'max-age=172800,stale-while-revalidate=86400'
header /_matrix/media/* Content-Security-Policy "sandbox; default-src 'none'; script-src 'none'; plugin-types application/pdf; style-src 'unsafe-inline'; object-src 'self';"
header /_matrix/media/* Cross-Origin-Resource-Policy 'cross-origin'
# Send all requests for URL previews to the DIP server
rewrite /_matrix/media/*/preview_url /preview_url
reverse_proxy /preview_url localhost:2226
# Send all other requests to the homeserver
reverse_proxy localhost:8008
}
```
You can most likely figure out how to do this with your chosen reverse proxy server if you aren't using Caddy.
### Example docker-compose.yml ### Example docker-compose.yml
```yaml ```yaml
version: "3" version: "3"