Files
hearth/nixos/system/neuro/wowmine-web.nix
T

105 lines
3.1 KiB
Nix

{ ... }:
{
networking.firewall.allowedTCPPorts = [ 80 443 ];
systemd.tmpfiles.rules = [
"d /var/www/wowmine 0755 root root -"
"d /var/www/wowmine/public/minecraft/wowmine/releases 0755 root root -"
];
security.acme = {
acceptTerms = true;
defaults.email = "security@bfs.band";
};
services.nginx = {
enable = true;
virtualHosts."wowmine-http" = {
serverName = "wowmine.bfs.band";
useACMEHost = "wowmine.bfs.band";
# Keep HTTP-01 challenges on80 while sending visitors to the public TLS port.
locations."/".return = "301 https://wowmine.bfs.band:8443$request_uri";
};
virtualHosts."wowmine.bfs.band" = {
enableACME = true;
onlySSL = true;
root = "/var/www/wowmine/public";
# Preserve the client's external port when8443 is forwarded to443.
extraConfig = ''
absolute_redirect off;
'';
locations = {
"= /" = {
return = "302 /wowmine/";
};
"= /wowmine" = {
return = "302 /wowmine/";
};
"^~ /wowmine/" = {
alias = "${./wowmine-site/static}/";
extraConfig = ''
index index.html;
autoindex off;
add_header Cache-Control "no-cache" always;
limit_except GET {
deny all;
}
'';
};
"= /wowmine/map" = {
return = "302 /wowmine/map/";
};
"^~ /wowmine/map/" = {
proxyPass = "http://127.0.0.1:8100/";
extraConfig = ''
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Connection "";
proxy_buffering off;
proxy_read_timeout 3600s;
limit_except GET {
deny all;
}
'';
};
"= /minecraft/wowmine" = {
return = "302 /minecraft/wowmine/";
};
"^~ /minecraft/wowmine/" = {
extraConfig = ''
index index.html;
autoindex off;
add_header Cache-Control "no-cache" always;
limit_except GET {
deny all;
}
try_files $uri $uri/ =404;
'';
};
"= /minecraft/world-of-sosal" = {
return = "301 /minecraft/wowmine/";
};
"^~ /minecraft/world-of-sosal/" = {
extraConfig = ''
rewrite ^/minecraft/world-of-sosal/WorldOfSosal-(.*)$ /minecraft/wowmine/wowmine-$1 permanent;
rewrite ^/minecraft/world-of-sosal/(.*)$ /minecraft/wowmine/$1 permanent;
'';
};
"= /world-of-sosal" = {
return = "302 /minecraft/wowmine/";
};
"^~ /world-of-sosal/" = {
extraConfig = ''
rewrite ^/world-of-sosal/(?:index.html)?$ /minecraft/wowmine/ permanent;
rewrite ^/world-of-sosal/(?:releases/)?WorldOfSosal-(.*)$ /minecraft/wowmine/wowmine-$1 permanent;
rewrite ^/world-of-sosal/(.*)$ /minecraft/wowmine/$1 permanent;
'';
};
"/" = {
return = "404";
};
};
};
};
}