matrix/templates/nginx.conf.tpl

81 lines
1.8 KiB
Smarty

upstream synapse {
server unix:/alloc/tmp/synapse.sock;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 127.0.0.1:8008 default_server;
server_tokens off;
root /opt/element;
index index.html;
include /etc/nginx/mime.types;
default_type application/octet-stream;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_socket_keepalive on;
proxy_buffering off;
proxy_request_buffering off;
client_max_body_size 100m;
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
location /_matrix {
proxy_pass http://synapse;
proxy_read_timeout 600;
}
location /_synapse {
proxy_pass http://synapse;
proxy_read_timeout 600;
}
location = /health {
access_log off;
proxy_pass http://synapse;
}
location /index.html {
add_header Cache-Control "no-cache";
}
location /version {
add_header Cache-Control "no-cache";
}
location /config.json {
add_header Cache-Control "no-cache";
alias /local/element.json;
}
location /.well-known/matrix/server {
add_header Access-Control-Allow-Origin *;
default_type application/json;
expires 6h;
return 200 '{"m.server": "[[ (urlParse .matrix.public_url).Hostname ]]:[[ if eq (urlParse .matrix.public_url).Port "" ]]443[[ else ]][[ (urlParse .matrix.public_url).Port ]][[ end ]]"}';
}
location /.well-known/matrix/client {
add_header Access-Control-Allow-Origin *;
default_type application/json;
expires 6h;
return 200 '{"m.homeserver": {"base_url": "[[ .matrix.public_url ]]"}}';
}
# Expose synapse admin
location /_admin/ {
alias /opt/synapse-admin/;
expires 30d;
}
# default files
location / {
expires 30d;
}
}