From fcb500fa1787a8a7eeb88d44d866cd485c0b048a Mon Sep 17 00:00:00 2001 From: pitchum Date: Sun, 10 Mar 2024 08:06:10 +0000 Subject: [PATCH] Provide nginx example config file --- debian/examples/nginx.conf | 78 ++++++++++++++++++++++++++++++++++++++ debian/mobilizon-docs.docs | 1 + 2 files changed, 79 insertions(+) create mode 100644 debian/examples/nginx.conf diff --git a/debian/examples/nginx.conf b/debian/examples/nginx.conf new file mode 100644 index 00000000..d07b557c --- /dev/null +++ b/debian/examples/nginx.conf @@ -0,0 +1,78 @@ +# Example nginx site config for Mobilizon on Debian +# +# Simple installation instructions: +# 1. Install your TLS certificate, possibly using Let's Encrypt. +# 2. Replace 'example.tld' with your instance's domain wherever it appears. +# 3. Copy this file to /etc/nginx/sites-available/ and then add a symlink to it +# in /etc/nginx/sites-enabled/ and run 'nginx -s reload' or restart nginx. + +server { + server_name example.tld; + + listen 80 default_server; + listen [::]:80 default_server; + + # Remove once HTTPS is setup + location ^~ '/.well-known/acme-challenge' { + root /var/www/certbot; + default_type "text/plain"; + } + + # Uncomment once HTTPS is setup + # return 301 https://$server_name$request_uri; +} + +server { + server_name example.tld; + + listen 443 ssl http2; + listen [::]:443 ssl http2; + + include /etc/nginx/snippets/snakeoil.conf; + # Replace the above line with the following once you have your own certificates + # ssl_trusted_certificate /etc/letsencrypt/live/example.tld/fullchain.pem; + # ssl_certificate /etc/letsencrypt/live/example.tld/fullchain.pem; + # ssl_certificate_key /etc/letsencrypt/live/example.tld/privkey.pem; + + add_header Strict-Transport-Security "max-age=31536000"; + + # the nginx default is 1m, not enough for large media uploads + client_max_body_size 16m; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + include proxy_params; + + location / { + expires off; + add_header Cache-Control "public, max-age=0, s-maxage=0, must-revalidate" always; + proxy_pass http://127.0.0.1:4000; + } + + # Let's Encrypt keeps its files here + location ^~ '/.well-known/acme-challenge' { + root /var/www/certbot; + default_type "text/plain"; + } + + location ~ ^/(assets|img) { + root /var/lib/mobilizon/priv/static; + access_log off; + add_header Cache-Control "public, max-age=31536000, s-maxage=31536000, immutable"; + } + + location ~ ^/(media|proxy) { + access_log off; + add_header Cache-Control "public, max-age=31536000, s-maxage=31536000, immutable"; + proxy_pass http://127.0.0.1:4000; + } + + error_page 500 501 502 503 504 @error; + location @error { + root /var/lib/mobilizon/priv/errors; + try_files /error.html 502; + } + +} + diff --git a/debian/mobilizon-docs.docs b/debian/mobilizon-docs.docs index c65f79b5..779a485c 100644 --- a/debian/mobilizon-docs.docs +++ b/debian/mobilizon-docs.docs @@ -1,2 +1,3 @@ debian/README.Debian.md debian/README.packaging.md +debian/examples/