Advertisement
ajhlinuxuser

PeerTube-502BadGateWay-nginx

Jan 1st, 2019
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.73 KB | None | 0 0
  1. server {
  2. listen 80;
  3. listen [::]:80;
  4. server_name tube1.tnkr.space;
  5.  
  6. access_log /var/log/nginx/tube1.tnkr.space.access.log;
  7. error_log /var/log/nginx/tube1.tnkr.space.error.log;
  8.  
  9. location /.well-known/acme-challenge/ {
  10. default_type "text/plain";
  11. root /var/www/certbot;
  12. }
  13. location / { return 301 https://$host$request_uri; }
  14. }
  15.  
  16. server {
  17. listen 443 ssl http2;
  18. listen [::]:443 ssl http2;
  19. server_name tube1.tnkr.space;
  20.  
  21. # For example with certbot (you need a certificate to run https)
  22. ssl_certificate /etc/letsencrypt/live/tube1.tnkr.space/fullchain.pem;
  23. ssl_certificate_key /etc/letsencrypt/live/tube1.tnkr.space/privkey.pem;
  24.  
  25. # Security hardening (as of 11/02/2018)
  26. ssl_protocols TLSv1.2; # TLSv1.3, TLSv1.2 if nginx >= 1.13.0
  27. ssl_prefer_server_ciphers on;
  28. 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';
  29. # ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0, not compatible with import-videos script
  30. ssl_session_timeout 10m;
  31. ssl_session_cache shared:SSL:10m;
  32. ssl_session_tickets off; # Requires nginx >= 1.5.9
  33. ssl_stapling on; # Requires nginx >= 1.3.7
  34. ssl_stapling_verify on; # Requires nginx => 1.3.7
  35.  
  36. # Configure with your resolvers
  37. # resolver $DNS-IP-1 $DNS-IP-2 valid=300s;
  38. # resolver_timeout 5s;
  39.  
  40. # Enable compression for JS/CSS/HTML bundle, for improved client load times.
  41. # It might be nice to compress JSON, but leaving that out to protect against potential
  42. # compression+encryption information leak attacks like BREACH.
  43. gzip on;
  44. gzip_types text/css text/html application/javascript;
  45. gzip_vary on;
  46.  
  47. # Enable HSTS
  48. # Tells browsers to stick with HTTPS and never visit the insecure HTTP
  49. # version. Once a browser sees this header, it will only visit the site over
  50. # HTTPS for the next 2 years: (read more on hstspreload.org)
  51. #add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
  52.  
  53. access_log /var/log/nginx/tube1.tnkr.space.access.log;
  54. error_log /var/log/nginx/tube1.tnkr.space.error.log;
  55.  
  56. location ^~ '/.well-known/acme-challenge' {
  57. default_type "text/plain";
  58. root /var/www/certbot;
  59. }
  60.  
  61. # Bypass PeerTube for performance reasons. Could be removed
  62. location ~ ^/client/(.*\.(js|css|woff2|otf|ttf|woff|eot))$ {
  63. add_header Cache-Control "public, max-age=31536000, immutable";
  64.  
  65. alias /var/www/peertube/peertube-latest/client/dist/$1;
  66. }
  67.  
  68. # Bypass PeerTube for performance reasons. Could be removed
  69. location ~ ^/static/(thumbnails|avatars)/ {
  70. if ($request_method = 'OPTIONS') {
  71. add_header 'Access-Control-Allow-Origin' '*';
  72. add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
  73. add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  74. add_header 'Access-Control-Max-Age' 1728000;
  75. add_header 'Content-Type' 'text/plain charset=UTF-8';
  76. add_header 'Content-Length' 0;
  77. return 204;
  78. }
  79.  
  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.  
  84. # Cache 2 hours
  85. add_header Cache-Control "public, max-age=7200";
  86.  
  87. root /var/www/peertube/storage;
  88.  
  89. rewrite ^/static/(thumbnails|avatars)/(.*)$ /$1/$2 break;
  90. try_files $uri /;
  91. }
  92.  
  93. location / {
  94. proxy_pass https://localhost:9000;
  95. proxy_set_header X-Real-IP $remote_addr;
  96. proxy_set_header Host $host;
  97. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  98.  
  99. # Hard limit, PeerTube does not support videos > 8GB
  100. client_max_body_size 8G;
  101. proxy_connect_timeout 600;
  102. proxy_send_timeout 600;
  103. proxy_read_timeout 600;
  104. send_timeout 600;
  105. }
  106.  
  107. # Bypass PeerTube for performance reasons. Could be removed
  108. location /static/webseed {
  109. # Clients usually have 4 simultaneous webseed connections, so the real limit is 3MB/s per client
  110. limit_rate 800k;
  111.  
  112. if ($request_method = 'OPTIONS') {
  113. add_header 'Access-Control-Allow-Origin' '*';
  114. add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
  115. add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  116. add_header 'Access-Control-Max-Age' 1728000;
  117. add_header 'Content-Type' 'text/plain charset=UTF-8';
  118. add_header 'Content-Length' 0;
  119. return 204;
  120. }
  121.  
  122. if ($request_method = 'GET') {
  123. add_header 'Access-Control-Allow-Origin' '*';
  124. add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
  125. add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  126.  
  127. # Don't spam access log file with byte range requests
  128. access_log off;
  129. }
  130.  
  131. alias /var/www/peertube/storage/videos;
  132. }
  133.  
  134. # Websocket tracker
  135. location /tracker/socket {
  136. # Peers send a message to the tracker every 15 minutes
  137. # Don't close the websocket before this time
  138. proxy_read_timeout 1200s;
  139. proxy_set_header Upgrade $http_upgrade;
  140. proxy_set_header Connection "upgrade";
  141. proxy_http_version 1.1;
  142. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  143. proxy_set_header Host $host;
  144. proxy_pass https://localhost:9000;
  145. }
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement