chore(access): tweak redirects

This commit is contained in:
arcnmx 2024-10-18 11:13:01 -07:00
parent 2c764ddf9a
commit ee5dc7aef2
6 changed files with 16 additions and 14 deletions

View file

@ -201,12 +201,14 @@
"/" = mkIf cfg.requireAuth { "/" = mkIf cfg.requireAuth {
vouch.requireAuth = mkAlmostOptionDefault true; vouch.requireAuth = mkAlmostOptionDefault true;
}; };
${cfg.auth.errorLocation} = mkIf (cfg.auth.errorLocation != null) { ${cfg.auth.errorLocation} = let
xvars.enable = true; errorLocation = { xvars, ... }: let
extraConfig = '' loginUrl = "$vouch_url/login?url=${xvars.get.scheme}://${xvars.get.host}$request_uri&X-Vouch-Token=$auth_resp_jwt&error=$auth_resp_err";
return 302 $vouch_url/login?url=${xvars.get.scheme}://${xvars.get.host}$request_uri&X-Vouch-Token=$auth_resp_jwt&error=$auth_resp_err; in {
''; xvars.enable = true;
}; return = mkDefault "303 '${loginUrl}'";
};
in mkIf (cfg.auth.errorLocation != null) errorLocation;
${cfg.auth.requestLocation} = { ${cfg.auth.requestLocation} = {
config, config,
xvars, xvars,

View file

@ -69,7 +69,7 @@ in {
inherit root extraConfig; inherit root extraConfig;
}; };
"/minecraft/wiki" = { "/minecraft/wiki" = {
return = "302 https://wiki.${domain}/minecraft/"; return = "301 https://wiki.${domain}/minecraft/";
}; };
"~ '^/minecraft/modpack/(\\S*)$'" = { "~ '^/minecraft/modpack/(\\S*)$'" = {
return = ''308 "https://gensokyo-zone.github.io/minecraft-modpack/$1"''; return = ''308 "https://gensokyo-zone.github.io/minecraft-modpack/$1"'';
@ -80,7 +80,7 @@ in {
then "bmap" then "bmap"
else "dmap"; else "dmap";
in { in {
return = "302 /minecraft/${defaultMap}/"; return = "308 /minecraft/${defaultMap}/";
}; };
"/minecraft/dmap/" = mkIf minecraft.ports.dynmap.enable { "/minecraft/dmap/" = mkIf minecraft.ports.dynmap.enable {
proxy = { proxy = {

View file

@ -82,7 +82,7 @@ in {
locations = locations =
{ {
"/" = { "/" = {
return = "302 /kitchen/"; return = "307 /kitchen/";
}; };
"/kitchen" = { "/kitchen" = {
proxy = { proxy = {

View file

@ -53,7 +53,7 @@ in {
headers.set.Cache-Control = "no-store, no-cache, must-revalidate"; headers.set.Cache-Control = "no-store, no-cache, must-revalidate";
}; };
"/webcam" = { "/webcam" = {
return = "302 /webcam/stream"; return = "307 /webcam/stream";
}; };
"/webcam/stream" = { "/webcam/stream" = {
proxy = { proxy = {

View file

@ -47,7 +47,7 @@ in {
}; };
locations = { locations = {
"~ ^/llama$" = { "~ ^/llama$" = {
return = mkDefault "302 /llama/"; return = mkDefault "308 /llama/";
}; };
"/llama/" = {virtualHost, ...}: { "/llama/" = {virtualHost, ...}: {
imports = [proxyLocation]; imports = [proxyLocation];
@ -62,12 +62,12 @@ in {
imports = [proxyLocation]; imports = [proxyLocation];
}; };
"~ '^/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'" = { "~ '^/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'" = {
return = mkDefault "302 /llama$request_uri"; return = mkDefault "307 /llama$request_uri";
}; };
"/" = {virtualHost, ...}: { "/" = {virtualHost, ...}: {
extraConfig = mkBefore '' extraConfig = mkBefore ''
if ($http_referer ~ '^https?://${escapeRegex virtualHost.serverName}/llama/') { if ($http_referer ~ '^https?://${escapeRegex virtualHost.serverName}/llama/') {
return 302 /llama$request_uri; return 307 /llama$request_uri;
} }
''; '';
return = mkDefault "404"; return = mkDefault "404";

View file

@ -31,7 +31,7 @@ in {
set $prox_plain $1; set $prox_plain $1;
} }
if ($prox_plain = $prox_expected) { if ($prox_plain = $prox_expected) {
return 302 https://$host/$prox_plain/; return 307 https://$host/$prox_plain/;
} }
if ($prox_plain != ''') { if ($prox_plain != ''') {
rewrite /(.*) /prox/$1 last; rewrite /(.*) /prox/$1 last;