dendrite/server/templates/nginx.conf.j2
author Luke Hoersten <luke@hoersten.org>
Sun, 11 Sep 2022 14:08:17 -0500
changeset 195 da34c8d7511d
parent 167 e3c49bf5fae9
child 200 10051617d075
permissions -rw-r--r--
Fixed uwsgi hosting for src.nth.io.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
119
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     1
server {
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     2
    listen 80;
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     3
    server_name {{nginx_server_name}};
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     4
    return 301 https://$host$request_uri;
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     5
}
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     6
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
     7
# Enable SSL session caching for improved performance
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
     8
ssl_session_cache shared:ssl_session_cache:10m;
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
     9
119
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    10
server {
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    11
    listen {{nginx_server_port}} ssl http2;
119
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    12
    server_name {{nginx_server_name}};
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    13
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    14
    ssl_certificate {{nginx_ssl_cert}};
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    15
    ssl_certificate_key {{nginx_ssl_privkey}};
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    16
    include /etc/letsencrypt/options-ssl-nginx.conf;
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    17
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
119
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    18
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    19
    ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    20
    ssl_stapling on;
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    21
    ssl_stapling_verify on;
119
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    22
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    23
    gzip_vary on;
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    24
    gzip_proxied any;
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    25
    gzip_comp_level 6;
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    26
    gzip_buffers 16 8k;
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    27
    gzip_http_version 1.1;
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    28
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript application/activity+json application/atom+xml;
119
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    29
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    30
    # the nginx default is 1m, not enough for large media uploads
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    31
    client_max_body_size 16m;
119
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    32
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    33
    proxy_set_header Host              $host;
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    34
    proxy_set_header X-Real-IP         $remote_addr;
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    35
    proxy_set_header X-Forwarded-For   $remote_addr;
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    36
    proxy_set_header X-Forwarded-Proto $scheme;
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    37
    proxy_read_timeout                 600;
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    38
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    39
    location /_matrix {
119
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    40
        proxy_pass http://127.0.0.1:{{nginx_proxy_port}};
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    41
    }
167
e3c49bf5fae9 Added index to dendrite nginx template.
Luke Hoersten <luke@hoersten.org>
parents: 163
diff changeset
    42
e3c49bf5fae9 Added index to dendrite nginx template.
Luke Hoersten <luke@hoersten.org>
parents: 163
diff changeset
    43
    root /var/www/{{nginx_server_name}};
e3c49bf5fae9 Added index to dendrite nginx template.
Luke Hoersten <luke@hoersten.org>
parents: 163
diff changeset
    44
    index index.html;
e3c49bf5fae9 Added index to dendrite nginx template.
Luke Hoersten <luke@hoersten.org>
parents: 163
diff changeset
    45
e3c49bf5fae9 Added index to dendrite nginx template.
Luke Hoersten <luke@hoersten.org>
parents: 163
diff changeset
    46
    location / {
e3c49bf5fae9 Added index to dendrite nginx template.
Luke Hoersten <luke@hoersten.org>
parents: 163
diff changeset
    47
        try_files $uri $uri/ =404;
e3c49bf5fae9 Added index to dendrite nginx template.
Luke Hoersten <luke@hoersten.org>
parents: 163
diff changeset
    48
    }
119
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    49
}