Infini-OPTIPLEX: simplify web setup
This commit is contained in:
parent
6fc8b69fff
commit
522df23288
1 changed files with 35 additions and 16 deletions
|
@ -1,9 +1,40 @@
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (config.common.nginx) ssl ssl-optional;
|
inherit (config.common.nginx) ssl ssl-optional;
|
||||||
|
|
||||||
|
tryFiles = "$uri $uri.html $uri/ =404";
|
||||||
|
websiteConfig = ''
|
||||||
|
error_page 403 /403.html;
|
||||||
|
error_page 404 /404.html;
|
||||||
|
|
||||||
|
location ^~ /.well-known { allow all; }
|
||||||
|
|
||||||
|
location = /template.html { deny all; }
|
||||||
|
location ~* "\.(nix|lock)" { deny all; }
|
||||||
|
location ~ "/\..+" { deny all; }
|
||||||
|
'';
|
||||||
|
|
||||||
|
mkWebsite = name: ssl // {
|
||||||
|
locations."/" = {
|
||||||
|
root = "/srv/web/${name}";
|
||||||
|
inherit tryFiles;
|
||||||
|
extraConfig = websiteConfig;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mkRedirect = from: to: ssl-optional // { globalRedirect = to; };
|
||||||
|
|
||||||
|
websites = lib.genAttrs [
|
||||||
|
"inx.moe"
|
||||||
|
"stickers.inx.moe"
|
||||||
|
] mkWebsite;
|
||||||
|
|
||||||
|
redirects = lib.mapAttrs mkRedirect {
|
||||||
|
"nitter.inx.moe" = "twitter.com";
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
services.nginx.virtualHosts = {
|
services.nginx.virtualHosts = websites // redirects // {
|
||||||
"blahaj.inx.moe" = ssl-optional // {
|
"blahaj.inx.moe" = ssl-optional // {
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
tryFiles = "/Blahaj.png =404";
|
tryFiles = "/Blahaj.png =404";
|
||||||
|
@ -21,25 +52,13 @@ in
|
||||||
"test.inx.moe" = ssl // {
|
"test.inx.moe" = ssl // {
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
root = "/srv/web/inx.moe";
|
root = "/srv/web/inx.moe";
|
||||||
tryFiles = "$uri $uri.html $uri/ =404";
|
inherit tryFiles;
|
||||||
extraConfig = ''
|
extraConfig = websiteConfig;
|
||||||
error_page 403 /403.html;
|
|
||||||
error_page 404 /404.html;
|
|
||||||
|
|
||||||
location ^~ /.well-known { allow all; }
|
|
||||||
|
|
||||||
location = /template.html { deny all; }
|
|
||||||
location ~* "\.(nix|lock)" { deny all; }
|
|
||||||
location ~ "/\..+" { deny all; }
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
"ponder.inx.moe" = ssl // {
|
"ponder.inx.moe" = ssl // {
|
||||||
locations."/".root = pkgs.ponder;
|
locations."/".root = pkgs.ponder;
|
||||||
};
|
};
|
||||||
"nitter.inx.moe" = ssl // {
|
|
||||||
globalRedirect = "twitter.com";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue