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
|
||||
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
|
||||
{
|
||||
services.nginx.virtualHosts = {
|
||||
services.nginx.virtualHosts = websites // redirects // {
|
||||
"blahaj.inx.moe" = ssl-optional // {
|
||||
locations."/" = {
|
||||
tryFiles = "/Blahaj.png =404";
|
||||
|
@ -21,25 +52,13 @@ in
|
|||
"test.inx.moe" = ssl // {
|
||||
locations."/" = {
|
||||
root = "/srv/web/inx.moe";
|
||||
tryFiles = "$uri $uri.html $uri/ =404";
|
||||
extraConfig = ''
|
||||
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; }
|
||||
'';
|
||||
inherit tryFiles;
|
||||
extraConfig = websiteConfig;
|
||||
};
|
||||
};
|
||||
|
||||
"ponder.inx.moe" = ssl // {
|
||||
locations."/".root = pkgs.ponder;
|
||||
};
|
||||
"nitter.inx.moe" = ssl // {
|
||||
globalRedirect = "twitter.com";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue