Helm chart for deploying Peertube on kubernetes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
6.1 KiB

  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: nginx-proxyconf
  5. data:
  6. peertubesite.conf: |-
  7. server {
  8. listen {{ .Values.nginxproxy.service.port }} default_server;
  9. listen [::]:{{ .Values.nginxproxy.service.port }} default_server;
  10. server_name _;
  11. error_log /var/log/nginx/error.log warn;
  12. access_log /var/log/nginx/access.log main;
  13. # Enable compression for JS/CSS/HTML bundle, for improved client load times.
  14. # It might be nice to compress JSON, but leaving that out to protect against potential
  15. # compression+encryption information leak attacks like BREACH.
  16. gzip on;
  17. gzip_types text/css application/javascript;
  18. gzip_vary on;
  19. # If you have a small /var/lib partition, it could be interesting to store temp nginx uploads in a different place
  20. # See https://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_temp_path
  21. client_body_temp_path /nginxtemp;
  22. # Bypass PeerTube for performance reasons. Could be removed
  23. location ~ ^/client/(.*\.(js|css|png|svg|woff2|otf|ttf|woff|eot))$ {
  24. add_header Cache-Control "public, max-age=31536000, immutable";
  25. alias /assets/$1;
  26. }
  27. # Bypass PeerTube for performance reasons. Could be removed
  28. location ~ ^/static/(thumbnails|avatars)/ {
  29. if ($request_method = 'OPTIONS') {
  30. add_header 'Access-Control-Allow-Origin' '*';
  31. add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
  32. add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  33. add_header 'Access-Control-Max-Age' 1728000;
  34. add_header 'Content-Type' 'text/plain charset=UTF-8';
  35. add_header 'Content-Length' 0;
  36. return 204;
  37. }
  38. add_header 'Access-Control-Allow-Origin' '*';
  39. add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
  40. add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  41. # Cache 2 hours
  42. add_header Cache-Control "public, max-age=7200";
  43. root /data;
  44. rewrite ^/static/(thumbnails|avatars)/(.*)$ /$1/$2 break;
  45. try_files $uri /;
  46. }
  47. location / {
  48. proxy_pass http://127.0.0.1:{{ .Values.service.port }};
  49. proxy_set_header X-Real-IP $remote_addr;
  50. proxy_set_header Host $host;
  51. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  52. # This is the maximum upload size, which roughly matches the maximum size of a video file
  53. # you can send via the API or the web interface. By default this is 8GB, but administrators
  54. # can increase or decrease the limit. Currently there's no way to communicate this limit
  55. # to users automatically, so you may want to leave a note in your instance 'about' page if
  56. # you change this.
  57. #
  58. # Note that temporary space is needed equal to the total size of all concurrent uploads.
  59. # This data gets stored in /var/lib/nginx by default, so you may want to put this directory
  60. # on a dedicated filesystem.
  61. #
  62. client_max_body_size {{ .Values.nginxproxy.maxbodysize }};
  63. # Default timeout to 50m to allow large upload with slow connection
  64. proxy_connect_timeout 3000;
  65. proxy_send_timeout 3000;
  66. proxy_read_timeout 3000;
  67. send_timeout 3000;
  68. }
  69. # Bypass PeerTube for performance reasons. Could be removed
  70. location ~ ^/static/(webseed|redundancy|streaming-playlists)/ {
  71. # Clients usually have 4 simultaneous webseed connections, so the real limit is 4MB/s per client
  72. set $peertube_limit_rate 1000k;
  73. # Increase rate limit in HLS mode, because we don't have multiple simultaneous connections
  74. if ($request_uri ~ -fragmented.mp4$) {
  75. set $peertube_limit_rate 5000k;
  76. }
  77. # Use this with nginx >= 1.17.0
  78. limit_rate $peertube_limit_rate;
  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. if ($request_method = 'GET') {
  89. add_header 'Access-Control-Allow-Origin' '*';
  90. add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
  91. add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  92. # Don't spam access log file with byte range requests
  93. access_log off;
  94. }
  95. root /data;
  96. rewrite ^/static/webseed/(.*)$ /videos/$1 break;
  97. rewrite ^/static/redundancy/(.*)$ /redundancy/$1 break;
  98. rewrite ^/static/streaming-playlists/(.*)$ /streaming-playlists/$1 break;
  99. try_files $uri /;
  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://127.0.0.1:{{ .Values.service.port }};
  112. }
  113. location /socket.io {
  114. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  115. proxy_set_header Host $host;
  116. proxy_pass http://127.0.0.1:{{ .Values.service.port }};
  117. # enable WebSockets
  118. proxy_http_version 1.1;
  119. proxy_set_header Upgrade $http_upgrade;
  120. proxy_set_header Connection "upgrade";
  121. }
  122. }