1 proxy_cache_path /var/cache/lemmy_frontend levels=1:2 keys_zone=lemmy_frontend_cache:10m max_size=100m use_temp_path=off;
2 limit_req_zone $binary_remote_addr zone=lemmy_ratelimit:10m rate=1r/s;
6 server_name {{ domain }};
7 location /.well-known/acme-challenge/ {
11 return 301 https://$host$request_uri;
17 server_name {{ domain }};
19 ssl_certificate /etc/letsencrypt/live/{{domain}}/fullchain.pem;
20 ssl_certificate_key /etc/letsencrypt/live/{{domain}}/privkey.pem;
22 # Various TLS hardening settings
23 # https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
24 ssl_protocols TLSv1.2 TLSv1.3;
25 ssl_prefer_server_ciphers on;
26 ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
27 ssl_session_timeout 10m;
28 ssl_session_cache shared:SSL:10m;
29 ssl_session_tickets off;
31 ssl_stapling_verify on;
36 # Enable compression for JS/CSS/HTML bundle, for improved client load times.
37 # It might be nice to compress JSON, but leaving that out to protect against potential
38 # compression+encryption information leak attacks like BREACH.
40 gzip_types text/css application/javascript image/svg+xml;
43 # Only connect to this site via HTTPS for the two years
44 add_header Strict-Transport-Security "max-age=63072000";
46 # Various content security headers
47 add_header Referrer-Policy "same-origin";
48 add_header X-Content-Type-Options "nosniff";
49 add_header X-Frame-Options "DENY";
50 add_header X-XSS-Protection "1; mode=block";
52 # Upload limit for pictrs
53 client_max_body_size 20M;
56 limit_req zone=lemmy_ratelimit burst=30 nodelay;
59 proxy_pass http://0.0.0.0:8536;
60 proxy_set_header X-Real-IP $remote_addr;
61 proxy_set_header Host $host;
62 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
65 proxy_http_version 1.1;
66 proxy_set_header Upgrade $http_upgrade;
67 proxy_set_header Connection "upgrade";
70 proxy_cache lemmy_frontend_cache;
71 proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
72 proxy_cache_revalidate on;
74 proxy_cache_min_uses 5;
77 # Redirect pictshare images to pictrs
78 location ~ /pictshare/(.*)$ {
79 return 301 /pictrs/image/$1;
84 location /pictrs/image {
85 proxy_pass http://0.0.0.0:8537/image;
86 proxy_set_header X-Real-IP $remote_addr;
87 proxy_set_header Host $host;
88 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
95 proxy_pass http://0.0.0.0:8061/;
96 proxy_set_header X-Real-IP $remote_addr;
97 proxy_set_header Host $host;
98 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
102 # Anonymize IP addresses
103 # https://www.supertechcrew.com/anonymizing-logs-nginx-apache/
104 map $remote_addr $remote_addr_anon {
105 ~(?P<ip>\d+\.\d+\.\d+)\. $ip.0;
106 ~(?P<ip>[^:]+:[^:]+): $ip::;
107 127.0.0.1 $remote_addr;
111 log_format main '$remote_addr_anon - $remote_user [$time_local] "$request" '
112 '$status $body_bytes_sent "$http_referer" "$http_user_agent"';
113 access_log /var/log/nginx/access.log main;