Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to configure the media path for reverse proxies #267

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

hashworks
Copy link
Contributor

Resolves #266.

Includes #238.

img-2023-09-25-194456

img-2023-09-25-194514

Nginx config used in the example above:

upstream synapse {
  server 127.0.0.1:8008;
  keepalive 20;
}

map $upstream_http_content_type $matrix_media {
    "text/plain"            "inline";
    "text/css"              "inline";

    "application/pdf"       "inline";

    "image/gif"             "inline";
    "image/jpeg"            "inline";
    "image/avif"            "inline";
    "image/png"             "inline";
    "image/tiff"            "inline";
    "image/vnd.wap.wbmp"    "inline";
    "image/webp"            "inline";
    "image/x-icon"          "inline";
    "image/x-jng"           "inline";
    "image/x-ms-bmp"        "inline";

    "audio/basic"           "inline";
    "audio/midi"            "inline";
    "audio/mpeg"            "inline";
    "audio/ogg"             "inline";
    "audio/x-m4a"           "inline";
    "audio/x-realaudio"     "inline";

    "video/3gpp"            "inline";
    "video/mp2t"            "inline";
    "video/mp4"             "inline";
    "video/mpeg"            "inline";
    "video/quicktime"       "inline";
    "video/webm"            "inline";
    "video/x-flv"           "inline";
    "video/x-m4v"           "inline";
    "video/x-matroska"      "inline";
    "video/x-mng"           "inline";
    "video/x-ms-asf"        "inline";
    "video/x-ms-wmv"        "inline";
    "video/x-msvideo"       "inline";

    default                 "attachement";
}


server {
  listen       *:443 ssl http2;
  listen       [::]:443 ssl http2 ;

  server_name  irc.hash.works;

  ssl_certificate           /etc/letsencrypt/live/irc.hash.works/fullchain.pem;
  ssl_certificate_key       /etc/letsencrypt/live/irc.hash.works/privkey.pem;

  location / {
    proxy_pass            http://synapse/_matrix/media/v3/download/kromlinger.eu/;
    proxy_http_version    1.1;
    proxy_set_header      Host $http_host;
    proxy_set_header      X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header      X-Forwarded-Proto $scheme;

    proxy_hide_header Content-Disposition;
    add_header Content-Disposition $matrix_media;
  }
}

@hifi
Copy link
Owner

hifi commented Sep 25, 2023

LGTM!

@hifi hifi merged commit 1763bad into hifi:master Sep 25, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Add ability to completely rewrite media URLs
2 participants