diff --git a/README.md b/README.md index 95a4412..1dcc9da 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,29 @@ pip install -r requirements.txt 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 ```yaml version: "3"