]>
Commit | Line | Data |
---|---|---|
c97eea23 C |
1 | server { |
2 | listen 80; | |
e883399f RK |
3 | listen [::]:80; |
4 | server_name peertube.example.com; | |
d2000ca6 | 5 | |
e883399f RK |
6 | access_log /var/log/nginx/peertube.example.com.access.log; |
7 | error_log /var/log/nginx/peertube.example.com.error.log; | |
5668bf2e | 8 | |
d2000ca6 C |
9 | location /.well-known/acme-challenge/ { allow all; } |
10 | location / { return 301 https://$host$request_uri; } | |
c97eea23 C |
11 | } |
12 | ||
13 | server { | |
85cd9bde | 14 | listen 443 ssl http2; |
e883399f RK |
15 | listen [::]:443 ssl http2; |
16 | server_name peertube.example.com; | |
c97eea23 | 17 | |
e883399f RK |
18 | # For example with Let's Encrypt (you need a certificate to run https) |
19 | ssl_certificate /etc/letsencrypt/live/peertube.example.com/fullchain.pem; | |
20 | ssl_certificate_key /etc/letsencrypt/live/peertube.example.com/privkey.pem; | |
21 | ||
22 | # Security hardening (as of 11/02/2018) | |
23 | ssl_protocols TLSv1.3, TLSv1.2;# TLSv1.3 requires nginx >= 1.13.0 else use only TLSv1.2 | |
24 | ssl_prefer_server_ciphers on; | |
25 | 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'; | |
26 | ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0 | |
27 | ssl_session_timeout 10m; | |
28 | ssl_session_cache shared:SSL:10m; | |
29 | ssl_session_tickets off; # Requires nginx >= 1.5.9 | |
30 | ssl_stapling on; # Requires nginx >= 1.3.7 | |
31 | ssl_stapling_verify on; # Requires nginx => 1.3.7 | |
32 | resolver $DNS-IP-1 $DNS-IP-2 valid=300s; | |
33 | resolver_timeout 5s; | |
34 | add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"; | |
35 | add_header X-Frame-Options DENY; | |
36 | add_header X-Content-Type-Options nosniff; | |
37 | add_header X-XSS-Protection "1; mode=block"; | |
38 | add_header X-Robots-Tag none; | |
39 | ||
40 | access_log /var/log/nginx/peertube.example.com.access.log; | |
41 | error_log /var/log/nginx/peertube.example.com.error.log; | |
5668bf2e | 42 | |
e883399f RK |
43 | location ^~ '/.well-known/acme-challenge' { |
44 | default_type "text/plain"; | |
45 | root /var/www/certbot; | |
46 | } | |
c97eea23 | 47 | |
5668bf2e C |
48 | location ~ ^/client/(.*\.(js|css|woff2|otf|ttf|woff|eot))$ { |
49 | add_header Cache-Control "public, max-age=31536000, immutable"; | |
50 | ||
59c48d49 | 51 | alias /var/www/peertube/peertube-latest/client/dist/$1; |
5668bf2e C |
52 | } |
53 | ||
2e866cc7 | 54 | location ~ ^/static/(thumbnails|avatars)/(.*)$ { |
5668bf2e C |
55 | add_header Cache-Control "public, max-age=31536000, immutable"; |
56 | ||
59c48d49 | 57 | alias /var/www/peertube/storage/$1/$2; |
5668bf2e C |
58 | } |
59 | ||
c97eea23 C |
60 | location / { |
61 | proxy_pass http://localhost:9000; | |
62 | proxy_set_header X-Real-IP $remote_addr; | |
63 | proxy_set_header Host $host; | |
64 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
65 | ||
66 | # For the video upload | |
aa83bcce | 67 | client_max_body_size 2G; |
7e9334c3 C |
68 | proxy_connect_timeout 600; |
69 | proxy_send_timeout 600; | |
70 | proxy_read_timeout 600; | |
e883399f | 71 | send_timeout 600; |
c97eea23 C |
72 | } |
73 | ||
74 | # Bypass PeerTube webseed route for better performances | |
75 | location /static/webseed { | |
85cd9bde C |
76 | # Clients usually have 4 simultaneous webseed connections, so the real limit is 3MB/s per client |
77 | limit_rate 800k; | |
78 | ||
c97eea23 C |
79 | if ($request_method = 'OPTIONS') { |
80 | add_header 'Access-Control-Allow-Origin' '*'; | |
81 | add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; | |
82 | add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; | |
83 | add_header 'Access-Control-Max-Age' 1728000; | |
84 | add_header 'Content-Type' 'text/plain charset=UTF-8'; | |
85 | add_header 'Content-Length' 0; | |
86 | return 204; | |
87 | } | |
88 | ||
89 | if ($request_method = 'GET') { | |
90 | add_header 'Access-Control-Allow-Origin' '*'; | |
91 | add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; | |
92 | add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; | |
5668bf2e C |
93 | |
94 | # Don't spam access log file with byte range requests | |
95 | access_log off; | |
c97eea23 C |
96 | } |
97 | ||
59c48d49 | 98 | alias /var/www/peertube/storage/videos; |
c97eea23 C |
99 | } |
100 | ||
101 | # Websocket tracker | |
102 | location /tracker/socket { | |
103 | # Peers send a message to the tracker every 15 minutes | |
104 | # Don't close the websocket before this time | |
105 | proxy_read_timeout 1200s; | |
106 | proxy_set_header Upgrade $http_upgrade; | |
107 | proxy_set_header Connection "upgrade"; | |
108 | proxy_http_version 1.1; | |
109 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
110 | proxy_set_header Host $host; | |
111 | proxy_pass http://localhost:9000; | |
112 | } | |
113 | } |