nginx: document how to enable CORS support
[akkoma] / installation / pleroma.nginx
1 proxy_cache_path /tmp/pleroma-media-cache levels=1:2 keys_zone=pleroma_media_cache:10m max_size=10g
2 inactive=720m use_temp_path=off;
3
4 server {
5 listen 80;
6 server_name example.tld;
7 return 301 https://$server_name$request_uri;
8 }
9
10 server {
11 listen 443 ssl http2;
12 ssl on;
13 ssl_session_timeout 5m;
14
15 ssl_certificate /etc/letsencrypt/live/exmaple.tld/fullchain.pem;
16 ssl_certificate_key /etc/letsencrypt/live/example.tld/privkey.pem;
17
18 ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
19 ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
20 ssl_prefer_server_ciphers on;
21
22 server_name example.tld;
23
24 gzip_vary on;
25 gzip_proxied any;
26 gzip_comp_level 6;
27 gzip_buffers 16 8k;
28 gzip_http_version 1.1;
29 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;
30 location / {
31 # if you do not want remote frontends to be able to access your Pleroma backend
32 # server, remove these lines.
33 add_header 'Access-Control-Allow-Origin' '*' always;
34 add_header 'Access-Control-Allow-Methods' 'POST, GET, OPTIONS' always;
35 add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type' always;
36 if ($request_method = OPTIONS) {
37 return 204;
38 }
39 # stop removing lines here.
40
41 proxy_http_version 1.1;
42 proxy_set_header Upgrade $http_upgrade;
43 proxy_set_header Connection "upgrade";
44 proxy_set_header Host $http_host;
45
46 proxy_pass http://localhost:4000;
47 }
48
49 location /proxy {
50 proxy_cache pleroma_media_cache;
51 proxy_cache_lock on;
52 proxy_pass http://localhost:4000;
53 }
54
55 }