1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-29 19:17:45 +00:00

fix: redirect to root domain for 404's

This commit is contained in:
RGBCube 2025-02-23 20:28:39 +03:00
parent 5609e12668
commit f3e93ee63e
3 changed files with 20 additions and 56 deletions

View file

@ -69,6 +69,13 @@ in {
};
services.nginx.virtualHosts.${fqdn} = merge config.services.nginx.sslTemplate {
extraConfig = /* nginx */ ''
# Grafana sets `nosniff` while not setting the content type properly,
# so everything breaks with it. Unset the header.
${config.services.nginx.headers}
add_header X-Content-Type-Options "" always;
'';
locations."/" = {
proxyPass = "http://[::1]:${toString port}";
proxyWebsockets = true;

View file

@ -2,8 +2,6 @@
inherit (config.networking) domain;
inherit (lib) const enabled genAttrs merge strings;
pathSite = "/var/www/site";
fqdn = "chat.${domain}";
port = 8002;
@ -24,24 +22,6 @@
"m.server" = "${fqdn}:443";
};
};
configNotFoundLocation = {
extraConfig = /* nginx */ ''
error_page 404 /404.html;
'';
locations."/".extraConfig = /* nginx */ ''
return 404;
'';
locations."/404".extraConfig = /* nginx */ ''
internal;
'';
locations."/assets/".extraConfig = /* nginx */ ''
return 301 https://${domain}$request_uri;
'';
};
in {
imports = [(self + /modules/nginx.nix)];
@ -103,8 +83,8 @@ in {
services.nginx.virtualHosts.${domain} = configWellKnownResponse;
services.nginx.virtualHosts.${fqdn} = merge config.services.nginx.sslTemplate configWellKnownResponse configNotFoundLocation {
root = pathSite;
services.nginx.virtualHosts.${fqdn} = merge config.services.nginx.sslTemplate configWellKnownResponse {
locations."/".return = "301 https://${domain}/404";
locations."/_matrix".proxyPass = "http://[::1]:${toString port}";
locations."/_synapse/client".proxyPass = "http://[::1]:${toString port}";