grace/dots
dotfiles/nix configs
git clone https://git.gae.moe/grace/dots
01e3245
main
1{ 2config , 3lib , 4pkgs , 5 ... 6} : 7 8let 9tailnet = import ../tailnet.nix ; 10auth = import ./nginx-auth.nix { }; 11staticSite = root :{ 12inherit root ; 13extraConfig = '' 14error_page 404 /404.html; 15 16# Redirect old homepage URLs to /. 17if ($request_uri ~ "^/index\.(?:html|htmlua|php)(?:\?|$)") { 18return 301 /$is_args$args; 19} 20 21# Redirect explicit page extensions to clean URLs. 22if ($request_uri ~ "^/([^?]+)\.(?:html|htmlua|php)(?:\?|$)") { 23return 301 /$1$is_args$args; 24} 25'' ; 26locations = { 27"/" . tryFiles = "$uri $uri.html $uri/ =404" ; 28"~ \\.wasm$" = { 29tryFiles = "$uri =404" ; 30extraConfig = '' 31types {} 32default_type application/wasm; 33'' ; 34}; 35"~ /rss\\.xml$" = { 36tryFiles = "$uri =404" ; 37extraConfig = '' 38types {} 39default_type application/rss+xml; 40'' ; 41}; 42"= /site.webmanifest" = { 43tryFiles = "$uri =404" ; 44extraConfig = '' 45types {} 46default_type application/manifest+json; 47'' ; 48}; 49"^~ /.well-known/" = { 50tryFiles = "$uri =404" ; 51extraConfig = '' 52types {} 53default_type text/plain; 54'' ; 55}; 56}; 57}; 58proxy = address :{ 59locations . "/" = { 60proxyPass = address ; 61proxyWebsockets = true ; 62extraConfig = "proxy_connect_timeout 10s;" ; 63}; 64}; 65protectedProxy = 66address : 67let 68host = proxy address ; 69in 70host 71// { 72locations = auth . locations // { 73"/" = host . locations . "/" // { 74extraConfig = host . locations . "/" . extraConfig + "\n" + auth . browser ; 75}; 76}; 77}; 78in 79{ 80imports = [ 81./authelia.nix 82./nginx-defaults.nix 83]; 84 85security . acme = { 86acceptTerms = true ; 87defaults . group = "nginx" ; 88}; 89 90networking . firewall . allowedTCPPorts = [ 9180 92443 9325565 94]; 95 96services . nginx = { 97enable = true ; 98recommendedProxySettings = true ; 99recommendedTlsSettings = true ; 100recommendedGzipSettings = true ; 101recommendedOptimisation = true ; 102clientMaxBodySize = "10g" ; 103proxyTimeout = "300s" ; 104appendHttpConfig = '' 105proxy_buffering off; 106proxy_request_buffering off; 107proxy_set_header Remote-User ""; 108proxy_set_header Remote-Groups ""; 109proxy_set_header Remote-Email ""; 110proxy_set_header Remote-Name ""; 111'' ; 112 113virtualHosts = { 114# all of these should be in their respective modules 115"auth.gae.moe" = proxy "http://127.0.0.1:9091" ; 116"fin.gae.moe" = proxy "http:// ${ tailnet . dijkstra } :8096" ; 117"files.gae.moe" = protectedProxy "http:// ${ tailnet . dijkstra } :8080" ; 118"img.gae.moe" = proxy "http:// ${ tailnet . dijkstra } :2283" ; 119 120"map.mc.gae.moe" = proxy "http:// ${ tailnet . dijkstra } :8101" ; 121 122"*.nate.gae.moe" = ( proxy "http:// ${ tailnet . nate-fedora } :80" ) // { 123enableACME = false ; 124forceSSL = false ; 125}; 126 127"grace.pink" = staticSite "/mnt/ext/git/www/private/grace.pink/main" ; 128"beta.grace.pink" = staticSite "/mnt/ext/git/www/private/grace.pink/beta" ; 129 130"some.words.gay" = staticSite "/mnt/ext/git/www/private/some.words.gay/main" ; 131"beta.some.words.gay" = staticSite "/mnt/ext/git/www/private/some.words.gay/beta" ; 132}; 133}; 134 135systemd . sockets . minecraft-proxy = { 136wantedBy = [ "sockets.target" ]; 137listenStreams = [ "0.0.0.0:25565" ]; 138}; 139systemd . services . minecraft-proxy = { 140description = "TCP proxy for Minecraft" ; 141requires = [ "minecraft-proxy.socket" ]; 142serviceConfig = { 143ExecStart = " ${ config . systemd . package } /lib/systemd/systemd-socket-proxyd ${ tailnet . dijkstra } :25565" ; 144DynamicUser = true ; 145}; 146}; 147}