author | Luke Hoersten <luke@hoersten.org> |
Tue, 26 Nov 2019 19:44:11 -0600 | |
changeset 81 | 5fe7c52b2063 |
parent 69 | be979818d483 |
child 82 | a3e1a9b18f6d |
permissions | -rw-r--r-- |
61
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
1 |
# default nginx site config for Pleroma |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
2 |
# |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
3 |
# Simple installation instructions: |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
4 |
# 1. Install your TLS certificate, possibly using Let's Encrypt. |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
5 |
# 2. Replace 'example.tld' with your instance's domain wherever it appears. |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
6 |
# 3. Copy this file to /etc/nginx/sites-available/ and then add a symlink to it |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
7 |
# in /etc/nginx/sites-enabled/ and run 'nginx -s reload' or restart nginx. |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
8 |
|
69 | 9 |
proxy_cache_path /tmp/{{pleroma_user}}-pleroma-media-cache levels=1:2 keys_zone={{pleroma_user}}-pleroma_media_cache:10m max_size=10g |
61
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
10 |
inactive=720m use_temp_path=off; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
11 |
|
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
12 |
server { |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
13 |
listen {{nginx_port}}; |
69 | 14 |
# listen [::]:{{nginx_port}}; |
61
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
15 |
server_name {{nginx_server_name}}; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
16 |
return 301 https://$server_name$request_uri; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
17 |
|
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
18 |
# Uncomment this if you need to use the 'webroot' method with certbot. Make sure |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
19 |
# that you also create the .well-known/acme-challenge directory structure in pleroma/priv/static and |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
20 |
# that is is accessible by the webserver. You may need to load this file with the ssl |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
21 |
# server block commented out, run certbot to get the certificate, and then uncomment it. |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
22 |
# |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
23 |
# location ~ /\.well-known/acme-challenge { |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
24 |
# root <path to install>/pleroma/priv/static/; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
25 |
# } |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
26 |
} |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
27 |
|
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
28 |
# Enable SSL session caching for improved performance |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
29 |
ssl_session_cache shared:ssl_session_cache:10m; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
30 |
|
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
31 |
server { |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
32 |
listen {{nginx_ssl_port}} ssl http2; |
69 | 33 |
# listen [::]:{{nginx_ssl_port}} ssl ipv6only=on; |
61
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
34 |
server_name {{nginx_server_name}}; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
35 |
|
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
36 |
ssl_certificate /etc/letsencrypt/live/{{nginx_server_name}}/fullchain.pem; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
37 |
ssl_certificate_key /etc/letsencrypt/live/{{nginx_server_name}}/privkey.pem; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
38 |
include /etc/letsencrypt/options-ssl-nginx.conf; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
39 |
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
40 |
|
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
41 |
ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
42 |
ssl_stapling on; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
43 |
ssl_stapling_verify on; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
44 |
|
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
45 |
add_header Strict-Transport-Security "max-age=31536000" always; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
46 |
|
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
47 |
gzip_vary on; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
48 |
gzip_proxied any; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
49 |
gzip_comp_level 6; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
50 |
gzip_buffers 16 8k; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
51 |
gzip_http_version 1.1; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
52 |
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; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
53 |
|
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
54 |
# the nginx default is 1m, not enough for large media uploads |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
55 |
client_max_body_size 16m; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
56 |
|
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
57 |
location / { |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
58 |
# if you do not want remote frontends to be able to access your Pleroma backend |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
59 |
# server, remove these lines. |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
60 |
# add_header 'Access-Control-Allow-Origin' '*' always; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
61 |
# add_header 'Access-Control-Allow-Methods' 'POST, PUT, DELETE, GET, PATCH, OPTIONS' always; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
62 |
# add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, Idempotency-Key' always; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
63 |
# add_header 'Access-Control-Expose-Headers' 'Link, X-RateLimit-Reset, X-RateLimit-Limit, X-RateLimit-Remaining, X-Request-Id' always; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
64 |
# if ($request_method = OPTIONS) { |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
65 |
# return 204; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
66 |
# } |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
67 |
# stop removing lines here. |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
68 |
|
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
69 |
add_header X-XSS-Protection "1; mode=block"; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
70 |
add_header X-Permitted-Cross-Domain-Policies none; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
71 |
add_header X-Frame-Options DENY; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
72 |
add_header X-Content-Type-Options nosniff; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
73 |
add_header Referrer-Policy same-origin; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
74 |
add_header X-Download-Options noopen; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
75 |
|
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
76 |
# Uncomment this only after you get HTTPS working. |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
77 |
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains"; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
78 |
|
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
79 |
proxy_http_version 1.1; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
80 |
proxy_set_header Upgrade $http_upgrade; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
81 |
proxy_set_header Connection "upgrade"; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
82 |
proxy_set_header Host $http_host; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
83 |
|
69 | 84 |
proxy_pass {{pleroma_proxy_pass}}; |
61
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
85 |
|
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
86 |
client_max_body_size 16m; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
87 |
} |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
88 |
|
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
89 |
location /proxy { |
69 | 90 |
proxy_cache {{pleroma_user}}-pleroma_media_cache; |
61
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
91 |
proxy_cache_lock on; |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
92 |
proxy_ignore_client_abort on; |
69 | 93 |
proxy_pass {{pleroma_proxy_pass}}; |
61
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
94 |
} |
2dd82d9e2103
Added nginx reverse proxy to pleroma.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
95 |
} |