lol

nixos/peertube: update nginx configuration

Izorkin 32673128 1915c85b

+79 -17
+79 -17
nixos/modules/services/web-apps/peertube.nix
··· 549 549 ''; 550 550 }; 551 551 552 + locations."~ ^/plugins/[^/]+(/[^/]+)?/ws/" = { 553 + tryFiles = "/dev/null @api_websocket"; 554 + priority = 1230; 555 + }; 556 + 552 557 locations."@api_websocket" = { 553 558 proxyPass = "http://127.0.0.1:${toString cfg.listenHttp}"; 554 - priority = 1230; 559 + priority = 1240; 555 560 556 561 extraConfig = '' 557 562 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; ··· 582 587 ''; 583 588 }; 584 589 585 - locations."~ ^/lazy-static/(avatars|banners)/" = { 590 + locations."^~ /lazy-static/avatars/" = { 586 591 tryFiles = "$uri @api"; 587 592 root = cfg.settings.storage.avatars; 588 593 priority = 1330; ··· 600 605 add_header Cache-Control 'public, max-age=7200'; 601 606 602 607 rewrite ^/lazy-static/avatars/(.*)$ /$1 break; 608 + ''; 609 + }; 610 + 611 + locations."^~ /lazy-static/banners/" = { 612 + tryFiles = "$uri @api"; 613 + root = cfg.settings.storage.avatars; 614 + priority = 1340; 615 + extraConfig = '' 616 + if ($request_method = 'OPTIONS') { 617 + ${nginxCommonHeaders} 618 + add_header Access-Control-Max-Age 1728000; 619 + add_header Cache-Control 'no-cache'; 620 + add_header Content-Type 'text/plain charset=UTF-8'; 621 + add_header Content-Length 0; 622 + return 204; 623 + } 624 + 625 + ${nginxCommonHeaders} 626 + add_header Cache-Control 'public, max-age=7200'; 627 + 603 628 rewrite ^/lazy-static/banners/(.*)$ /$1 break; 604 629 ''; 605 630 }; ··· 607 632 locations."^~ /lazy-static/previews/" = { 608 633 tryFiles = "$uri @api"; 609 634 root = cfg.settings.storage.previews; 610 - priority = 1340; 635 + priority = 1350; 611 636 extraConfig = '' 612 637 if ($request_method = 'OPTIONS') { 613 638 ${nginxCommonHeaders} ··· 625 650 ''; 626 651 }; 627 652 653 + locations."^~ /static/streaming-playlists/private/" = { 654 + proxyPass = "http://127.0.0.1:${toString cfg.listenHttp}"; 655 + priority = 1410; 656 + extraConfig = '' 657 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 658 + proxy_set_header Host $host; 659 + proxy_set_header X-Real-IP $remote_addr; 660 + 661 + proxy_limit_rate 5M; 662 + ''; 663 + }; 664 + 665 + locations."^~ /static/webseed/private/" = { 666 + proxyPass = "http://127.0.0.1:${toString cfg.listenHttp}"; 667 + priority = 1420; 668 + extraConfig = '' 669 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 670 + proxy_set_header Host $host; 671 + proxy_set_header X-Real-IP $remote_addr; 672 + 673 + proxy_limit_rate 5M; 674 + ''; 675 + }; 676 + 628 677 locations."^~ /static/thumbnails/" = { 629 678 tryFiles = "$uri @api"; 630 679 root = cfg.settings.storage.thumbnails; 631 - priority = 1350; 680 + priority = 1430; 632 681 extraConfig = '' 633 682 if ($request_method = 'OPTIONS') { 634 683 ${nginxCommonHeaders} ··· 649 698 locations."^~ /static/redundancy/" = { 650 699 tryFiles = "$uri @api"; 651 700 root = cfg.settings.storage.redundancy; 652 - priority = 1360; 701 + priority = 1440; 653 702 extraConfig = '' 703 + set $peertube_limit_rate 800k; 704 + 705 + if ($request_uri ~ -fragmented.mp4$) { 706 + set $peertube_limit_rate 5M; 707 + } 708 + 654 709 if ($request_method = 'OPTIONS') { 655 710 ${nginxCommonHeaders} 656 711 add_header Access-Control-Max-Age 1728000; ··· 663 718 664 719 access_log off; 665 720 } 721 + 666 722 aio threads; 667 723 sendfile on; 668 724 sendfile_max_chunk 1M; 669 725 726 + limit_rate $peertube_limit_rate; 670 727 limit_rate_after 5M; 671 - 672 - set $peertube_limit_rate 800k; 673 - set $limit_rate $peertube_limit_rate; 674 728 675 729 rewrite ^/static/redundancy/(.*)$ /$1 break; 676 730 ''; ··· 679 733 locations."^~ /static/streaming-playlists/" = { 680 734 tryFiles = "$uri @api"; 681 735 root = cfg.settings.storage.streaming_playlists; 682 - priority = 1370; 736 + priority = 1450; 683 737 extraConfig = '' 738 + set $peertube_limit_rate 800k; 739 + 740 + if ($request_uri ~ -fragmented.mp4$) { 741 + set $peertube_limit_rate 5M; 742 + } 743 + 684 744 if ($request_method = 'OPTIONS') { 685 745 ${nginxCommonHeaders} 686 746 add_header Access-Control-Max-Age 1728000; ··· 698 758 sendfile on; 699 759 sendfile_max_chunk 1M; 700 760 761 + limit_rate $peertube_limit_rate; 701 762 limit_rate_after 5M; 702 - 703 - set $peertube_limit_rate 5M; 704 - set $limit_rate $peertube_limit_rate; 705 763 706 764 rewrite ^/static/streaming-playlists/(.*)$ /$1 break; 707 765 ''; 708 766 }; 709 767 710 - locations."~ ^/static/webseed/" = { 768 + locations."^~ /static/webseed/" = { 711 769 tryFiles = "$uri @api"; 712 770 root = cfg.settings.storage.videos; 713 - priority = 1380; 771 + priority = 1460; 714 772 extraConfig = '' 773 + set $peertube_limit_rate 800k; 774 + 775 + if ($request_uri ~ -fragmented.mp4$) { 776 + set $peertube_limit_rate 5M; 777 + } 778 + 715 779 if ($request_method = 'OPTIONS') { 716 780 ${nginxCommonHeaders} 717 781 add_header Access-Control-Max-Age 1728000; ··· 729 793 sendfile on; 730 794 sendfile_max_chunk 1M; 731 795 796 + limit_rate $peertube_limit_rate; 732 797 limit_rate_after 5M; 733 - 734 - set $peertube_limit_rate 800k; 735 - set $limit_rate $peertube_limit_rate; 736 798 737 799 rewrite ^/static/webseed/(.*)$ /$1 break; 738 800 '';