]> cat aescling's git repositories - mastodon.git/blob - dist/nginx.conf
Bump rubocop from 1.11.0 to 1.12.0 (#15970)
[mastodon.git] / dist / nginx.conf
1 map $http_upgrade $connection_upgrade {
2 default upgrade;
3 '' close;
4 }
5
6 upstream backend {
7 server 127.0.0.1:3000 fail_timeout=0;
8 }
9
10 upstream streaming {
11 server 127.0.0.1:4000 fail_timeout=0;
12 }
13
14 proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=CACHE:10m inactive=7d max_size=1g;
15
16 server {
17 listen 80;
18 listen [::]:80;
19 server_name example.com;
20 root /home/mastodon/live/public;
21 location /.well-known/acme-challenge/ { allow all; }
22 location / { return 301 https://$host$request_uri; }
23 }
24
25 server {
26 listen 443 ssl http2;
27 listen [::]:443 ssl http2;
28 server_name example.com;
29
30 ssl_protocols TLSv1.2 TLSv1.3;
31 ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA;
32 ssl_prefer_server_ciphers on;
33 ssl_session_cache shared:SSL:10m;
34
35 # Uncomment these lines once you acquire a certificate:
36 # ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
37 # ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
38
39 keepalive_timeout 70;
40 sendfile on;
41 client_max_body_size 80m;
42
43 root /home/mastodon/live/public;
44
45 gzip on;
46 gzip_disable "msie6";
47 gzip_vary on;
48 gzip_proxied any;
49 gzip_comp_level 6;
50 gzip_buffers 16 8k;
51 gzip_http_version 1.1;
52 gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
53
54 add_header Strict-Transport-Security "max-age=31536000";
55
56 location / {
57 try_files $uri @proxy;
58 }
59
60 location ~ ^/(emoji|packs|system/accounts/avatars|system/media_attachments/files) {
61 add_header Cache-Control "public, max-age=31536000, immutable";
62 add_header Strict-Transport-Security "max-age=31536000";
63 try_files $uri @proxy;
64 }
65
66 location /sw.js {
67 add_header Cache-Control "public, max-age=0";
68 add_header Strict-Transport-Security "max-age=31536000";
69 try_files $uri @proxy;
70 }
71
72 location @proxy {
73 proxy_set_header Host $host;
74 proxy_set_header X-Real-IP $remote_addr;
75 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
76 proxy_set_header X-Forwarded-Proto $scheme;
77 proxy_set_header Proxy "";
78 proxy_pass_header Server;
79
80 proxy_pass http://backend;
81 proxy_buffering on;
82 proxy_redirect off;
83 proxy_http_version 1.1;
84 proxy_set_header Upgrade $http_upgrade;
85 proxy_set_header Connection $connection_upgrade;
86
87 proxy_cache CACHE;
88 proxy_cache_valid 200 7d;
89 proxy_cache_valid 410 24h;
90 proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
91 add_header X-Cached $upstream_cache_status;
92 add_header Strict-Transport-Security "max-age=31536000";
93
94 tcp_nodelay on;
95 }
96
97 location /api/v1/streaming {
98 proxy_set_header Host $host;
99 proxy_set_header X-Real-IP $remote_addr;
100 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
101 proxy_set_header X-Forwarded-Proto $scheme;
102 proxy_set_header Proxy "";
103
104 proxy_pass http://streaming;
105 proxy_buffering off;
106 proxy_redirect off;
107 proxy_http_version 1.1;
108 proxy_set_header Upgrade $http_upgrade;
109 proxy_set_header Connection $connection_upgrade;
110
111 tcp_nodelay on;
112 }
113
114 error_page 500 501 502 503 504 /500.html;
115 }
This page took 0.096989 seconds and 4 git commands to generate.