diff --git a/README.md b/README.md index 75bf769a977b1e55ca64bd80d744bc1cf3dc1a2a..f0bf4dd9bbb069a1bef2ece46ac8103ca4b7e712 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # matrix-media-repo -A host-aware media repository for Matrix. Designed for environments with multiple homeservers. -Talk about it in [#media-repo:t2bot.io](https://matrix.to/#/#media-repo:t2bot.io). +A host-aware media repository for Matrix. For development news and support, please visit [#media-repo:t2bot.io](https://matrix.to/#/#media-repo:t2bot.io). + +Designed for environments with multiple homeservers, matrix-media-repo de-duplicates all media automatically, including remote content. Environments with only one homeserver can still make use of the de-duplication and performance of matrix-media-repo. # Installing @@ -21,4 +22,28 @@ cp config.sample.yaml media-repo.yaml # Run it bin/matrix-media-repo +``` + +# Deployment + +This is intended to run behind a load balancer and beside your homeserver deployments. A sample nginx configuration for this is: + +```ini +# Redirect all matrix traffic by default to the homeserver +location /_matrix { + proxy_read_timeout 60s; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_pass http://localhost:8008; # Point this towards your homeserver +} + +# Redirect all media endpoints to the media-repo +location /_matrix/client/r0/media { + proxy_read_timeout 60s; + proxy_set_header Host $host; # Make sure this matches your homeserver in media-repo.yaml + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_pass http://localhost:8000; # Point this towards media-repo +} ``` \ No newline at end of file diff --git a/config.sample.yaml b/config.sample.yaml index bb02958f88d8a52cd64c9967f75cf714c0e9171f..3bc6a942d861adbf59565bac95bfe9807c0008cc 100644 --- a/config.sample.yaml +++ b/config.sample.yaml @@ -1,3 +1,5 @@ +# The configuration for the homeservers this media repository is known to control. Servers +# not listed here will not be able to upload media. # NOT YET IMPLEMENTED homeservers: - name: t2bot.io @@ -7,17 +9,18 @@ homeservers: downloadRequiresAuth: false csApi: "https://t2l.io/" -# NOT YET IMPLEMENTED +# The database configuration for the media repository database: # Currently only "postgres" is supported. - postgres: "postgres://mediarepo:yourpassword@localhost/media-repository?sslmode=disable" + postgres: "postgres://your_username:your_password@localhost/database_name?sslmode=disable" uploads: - # A location will be picked based upon estimated folder size - # DISTRIBUTION NOT YET IMPLEMENTED + maxBytes: 10485760 # 10MB default, 0 to disable + # This is intended for larger deployments where media should be distributed among other + # directories, drives, servers, etc. For smaller deployments, a single entry in this list + # is recommended. storagePaths: - /var/matrix/media - maxBytes: 10485760 # 10MB default, 0 to disable # NOT YET IMPLEMENTED thumbails: