use error_page instead of try_files?????

This commit is contained in:
chaos 2023-09-04 18:26:57 +01:00
parent 13d55d7293
commit 89c40d8046
No known key found for this signature in database
2 changed files with 8 additions and 11 deletions

View file

@ -10,12 +10,17 @@ with lib; let
pkgs.piped-frontend.override {backendDomain = cfg.backendDomain;}; pkgs.piped-frontend.override {backendDomain = cfg.backendDomain;};
in { in {
config = mkIf (cfg.enable && !cfg.disableFrontend && !cfg.disableNginx) { config = mkIf (cfg.enable && !cfg.disableFrontend && !cfg.disableNginx) {
# https://github.com/TeamPiped/Piped/blob/master/docker/nginx.conf
services.nginx.virtualHosts."${cfg.frontendDomain}" = { services.nginx.virtualHosts."${cfg.frontendDomain}" = {
forceSSL = cfg.nginxForceSSL; forceSSL = cfg.nginxForceSSL;
enableACME = cfg.nginxEnableACME; enableACME = cfg.nginxEnableACME;
locations."/".root = "${frontend-package}/share/piped-frontend"; locations."/" = {
root = "${frontend-package}/share/piped-frontend";
index = "index.html index.htm";
};
# I have no idea why try_files for Single Page Apps doesn't work here
extraConfig = '' extraConfig = ''
try_files $uri $uri/ /index.html; error_page 404 =200 /index.html;
''; '';
}; };
}; };

View file

@ -94,20 +94,12 @@ in {
}; };
}; };
services.nginx.virtualHosts."piped.owo.monster" = let services.nginx.virtualHosts."piped.owo.monster" = {
backendDomain = "backend.piped.owo.monster";
frontend-package = pkgs.piped-frontend.override {
inherit backendDomain;
};
in {
forceSSL = true; forceSSL = true;
enableACME = true; enableACME = true;
locations."/" = { locations."/" = {
proxyPass = "http://unix:${pipedSocketForComponent "frontend"}"; proxyPass = "http://unix:${pipedSocketForComponent "frontend"}";
}; };
extraConfig = ''
try_files $uri $uri/ /index.html;
'';
}; };
services.nginx.virtualHosts."backend.piped.owo.monster" = { services.nginx.virtualHosts."backend.piped.owo.monster" = {