writefreely/server/templates/nginx.conf.j2
author Luke Hoersten <luke@hoersten.org>
Sat, 11 Feb 2023 10:49:06 -0600
changeset 209 81014d20e5b1
parent 202 252069788104
permissions -rw-r--r--
Use rsync for nginx root copy.
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
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     7
server {
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     8
    listen 443 ssl http2;
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     9
    server_name {{nginx_server_name}};
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    10
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    11
    ssl_certificate {{nginx_ssl_cert}};
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    12
    ssl_certificate_key {{nginx_ssl_privkey}};
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    13
    ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    14
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    15
    gzip on;
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    16
    gzip_types
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    17
      application/javascript
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    18
      application/x-javascript
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    19
      application/json
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    20
      application/rss+xml
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    21
      application/xml
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    22
      image/svg+xml
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    23
      image/x-icon
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    24
      application/vnd.ms-fontobject
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    25
      application/font-sfnt
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    26
      text/css
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    27
      text/plain;
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    28
    gzip_min_length 256;
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    29
    gzip_comp_level 5;
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    30
    gzip_http_version 1.1;
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    31
    gzip_vary on;
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    32
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    33
    location ~ ^/.well-known/(webfinger|nodeinfo|host-meta) {
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    34
        proxy_set_header Host $host;
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    35
        proxy_set_header X-Real-IP $remote_addr;
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    36
        proxy_set_header X-Forwarded-For $remote_addr;
202
252069788104 Backed out changeset 10051617d075
Luke Hoersten <luke@hoersten.org>
parents: 200
diff changeset
    37
        proxy_pass http://127.0.0.1:{{nginx_proxy_port}};
119
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    38
        proxy_redirect off;
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    39
    }
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    40
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    41
    location ~ ^/(css|img|js|fonts)/ {
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    42
        root {{nginx_static_content}};
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    43
        # Optionally cache these files in the browser:
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    44
        # expires 12M;
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    45
    }
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    46
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    47
    location / {
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    48
        proxy_set_header Host $host;
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    49
        proxy_set_header X-Real-IP $remote_addr;
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    50
        proxy_set_header X-Forwarded-For $remote_addr;
202
252069788104 Backed out changeset 10051617d075
Luke Hoersten <luke@hoersten.org>
parents: 200
diff changeset
    51
        proxy_pass http://127.0.0.1:{{nginx_proxy_port}};
119
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    52
        proxy_redirect off;
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    53
    }
a96a5eb96e32 Added nginx config template.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    54
}