Files
matrix-synapse/nginx.conf.tmpl

66 lines
1.7 KiB
Cheetah

user www-data;
events {
worker_connections 768;
}
http {
resolver 127.0.0.11 valid=30s ipv6=off;
resolver_timeout 5s;
upstream matrix_upstream {
zone matrix_upstream 64k;
server {{ env "STACK_NAME"}}_app:8008 resolve;
keepalive 16;
}
server {
listen 80;
access_log {{ or (env "NGINX_ACCESS_LOG_LOCATION") "/dev/null" }};
error_log {{ or (env "NGINX_ERROR_LOG_LOCATION") "/dev/null" }};
server_name {{ env "DOMAIN" }};
location = / {
proxy_pass http://matrix_upstream;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $host;
client_max_body_size {{ or (env "MAX_UPLOAD_SIZE") "50M" }}
proxy_http_version 1.1;
}
location ~* ^(\/_matrix|\/_synapse\/client) {
proxy_pass http://matrix_upstream;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $host;
client_max_body_size {{ or (env "MAX_UPLOAD_SIZE") "50M" }};
proxy_http_version 1.1;
}
location /.well-known/matrix/ {
root /var/www/;
default_type application/json;
add_header Access-Control-Allow-Origin *;
}
{{ if eq (env "ADMIN_INTERFACE_ENABLED") "1" }}
location ^~ /_synapse/admin {
if ($http_referer !~ "^https://{{ env "DOMAIN" }}/admin/") {
return 403;
}
proxy_pass http://matrix_upstream;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $host;
client_max_body_size {{ or (env "MAX_UPLOAD_SIZE") "50M" }};
proxy_http_version 1.1;
}
{{ end }}
}
}