]>
Commit | Line | Data |
---|---|---|
c97eea23 C |
1 | server { |
2 | listen 80; | |
3 | # listen [::]:80; | |
4 | server_name domain.tld; | |
d2000ca6 | 5 | |
5668bf2e C |
6 | access_log /var/log/nginx/peertube_access.log; |
7 | error_log /var/log/nginx/peertube_error.log; | |
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 C |
14 | listen 443 ssl http2; |
15 | # listen [::]:443 ssl http2; | |
c97eea23 C |
16 | server_name domain.tld; |
17 | ||
5668bf2e C |
18 | access_log /var/log/nginx/peertube_access.log; |
19 | error_log /var/log/nginx/peertube_error.log; | |
20 | ||
c97eea23 C |
21 | # For example with Let's Encrypt |
22 | ssl_certificate /etc/letsencrypt/live/domain.tld/fullchain.pem; | |
23 | ssl_certificate_key /etc/letsencrypt/live/domain.tld/privkey.pem; | |
24 | ssl_trusted_certificate /etc/letsencrypt/live/domain.tld/chain.pem; | |
25 | ||
5668bf2e C |
26 | location ~ ^/client/(.*\.(js|css|woff2|otf|ttf|woff|eot))$ { |
27 | add_header Cache-Control "public, max-age=31536000, immutable"; | |
28 | ||
59c48d49 | 29 | alias /var/www/peertube/peertube-latest/client/dist/$1; |
5668bf2e C |
30 | } |
31 | ||
2e866cc7 | 32 | location ~ ^/static/(thumbnails|avatars)/(.*)$ { |
5668bf2e C |
33 | add_header Cache-Control "public, max-age=31536000, immutable"; |
34 | ||
59c48d49 | 35 | alias /var/www/peertube/storage/$1/$2; |
5668bf2e C |
36 | } |
37 | ||
c97eea23 C |
38 | location / { |
39 | proxy_pass http://localhost:9000; | |
40 | proxy_set_header X-Real-IP $remote_addr; | |
41 | proxy_set_header Host $host; | |
42 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
43 | ||
44 | # For the video upload | |
aa83bcce | 45 | client_max_body_size 2G; |
7e9334c3 C |
46 | proxy_connect_timeout 600; |
47 | proxy_send_timeout 600; | |
48 | proxy_read_timeout 600; | |
c97eea23 C |
49 | } |
50 | ||
51 | # Bypass PeerTube webseed route for better performances | |
52 | location /static/webseed { | |
85cd9bde C |
53 | # Clients usually have 4 simultaneous webseed connections, so the real limit is 3MB/s per client |
54 | limit_rate 800k; | |
55 | ||
c97eea23 C |
56 | if ($request_method = 'OPTIONS') { |
57 | add_header 'Access-Control-Allow-Origin' '*'; | |
58 | add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; | |
59 | add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; | |
60 | add_header 'Access-Control-Max-Age' 1728000; | |
61 | add_header 'Content-Type' 'text/plain charset=UTF-8'; | |
62 | add_header 'Content-Length' 0; | |
63 | return 204; | |
64 | } | |
65 | ||
66 | if ($request_method = 'GET') { | |
67 | add_header 'Access-Control-Allow-Origin' '*'; | |
68 | add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; | |
69 | 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 |
70 | |
71 | # Don't spam access log file with byte range requests | |
72 | access_log off; | |
c97eea23 C |
73 | } |
74 | ||
59c48d49 | 75 | alias /var/www/peertube/storage/videos; |
c97eea23 C |
76 | } |
77 | ||
78 | # Websocket tracker | |
79 | location /tracker/socket { | |
80 | # Peers send a message to the tracker every 15 minutes | |
81 | # Don't close the websocket before this time | |
82 | proxy_read_timeout 1200s; | |
83 | proxy_set_header Upgrade $http_upgrade; | |
84 | proxy_set_header Connection "upgrade"; | |
85 | proxy_http_version 1.1; | |
86 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
87 | proxy_set_header Host $host; | |
88 | proxy_pass http://localhost:9000; | |
89 | } | |
90 | } |