3 tv.nginx: allow multiple server blocks
This commit is contained in:
parent
814eae09ff
commit
90eff04849
|
@ -32,7 +32,7 @@ with lib;
|
||||||
imports = [ ../../3modules/tv/nginx.nix ];
|
imports = [ ../../3modules/tv/nginx.nix ];
|
||||||
tv.nginx = {
|
tv.nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
retiolum-locations = [
|
servers.default.locations = [
|
||||||
(nameValuePair "~ ^/~(.+?)(/.*)?\$" ''
|
(nameValuePair "~ ^/~(.+?)(/.*)?\$" ''
|
||||||
alias /home/$1/public_html$2;
|
alias /home/$1/public_html$2;
|
||||||
'')
|
'')
|
||||||
|
|
|
@ -133,7 +133,7 @@ with lib;
|
||||||
imports = [ ../../3modules/tv/nginx.nix ];
|
imports = [ ../../3modules/tv/nginx.nix ];
|
||||||
tv.nginx = {
|
tv.nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
retiolum-locations = [
|
servers.default.locations = [
|
||||||
(nameValuePair "~ ^/~(.+?)(/.*)?\$" ''
|
(nameValuePair "~ ^/~(.+?)(/.*)?\$" ''
|
||||||
alias /home/$1/public_html$2;
|
alias /home/$1/public_html$2;
|
||||||
'')
|
'')
|
||||||
|
|
|
@ -212,7 +212,7 @@ let
|
||||||
|
|
||||||
tv.nginx = {
|
tv.nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
retiolum-locations = [
|
servers.default.locations = [
|
||||||
(nameValuePair "/cgit/" ''
|
(nameValuePair "/cgit/" ''
|
||||||
include ${pkgs.nginx}/conf/fastcgi_params;
|
include ${pkgs.nginx}/conf/fastcgi_params;
|
||||||
fastcgi_param SCRIPT_FILENAME ${pkgs.cgit}/cgit/cgit.cgi;
|
fastcgi_param SCRIPT_FILENAME ${pkgs.cgit}/cgit/cgit.cgi;
|
||||||
|
|
|
@ -13,46 +13,41 @@ let
|
||||||
api = {
|
api = {
|
||||||
enable = mkEnableOption "tv.nginx";
|
enable = mkEnableOption "tv.nginx";
|
||||||
|
|
||||||
retiolum-locations = mkOption {
|
servers = mkOption {
|
||||||
type = with types; listOf (attrsOf str);
|
type = with types; attrsOf optionSet;
|
||||||
default = [];
|
options = singleton {
|
||||||
|
server-names = mkOption {
|
||||||
|
type = with types; listOf str;
|
||||||
|
default = [
|
||||||
|
"${config.networking.hostName}"
|
||||||
|
"${config.networking.hostName}.retiolum"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
locations = mkOption {
|
||||||
|
type = with types; listOf (attrsOf str);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
default = {};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
imp = {
|
imp = {
|
||||||
services.nginx =
|
services.nginx = {
|
||||||
let
|
enable = true;
|
||||||
name = config.tv.retiolum.name;
|
httpConfig = ''
|
||||||
qname = "${name}.retiolum";
|
include ${pkgs.nginx}/conf/mime.types;
|
||||||
in
|
default_type application/octet-stream;
|
||||||
assert config.tv.retiolum.enable;
|
sendfile on;
|
||||||
{
|
keepalive_timeout 65;
|
||||||
enable = true;
|
gzip on;
|
||||||
httpConfig = ''
|
server {
|
||||||
include ${pkgs.nginx}/conf/mime.types;
|
listen 80 default_server;
|
||||||
default_type application/octet-stream;
|
server_name _;
|
||||||
sendfile on;
|
return 404;
|
||||||
keepalive_timeout 65;
|
}
|
||||||
gzip on;
|
${concatStrings (mapAttrsToList (_: to-server) cfg.servers)}
|
||||||
server {
|
'';
|
||||||
listen 80 default_server;
|
};
|
||||||
server_name _;
|
|
||||||
location / {
|
|
||||||
return 404;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name ${name} ${qname};
|
|
||||||
|
|
||||||
${indent (concatStrings (map to-location cfg.retiolum-locations))}
|
|
||||||
|
|
||||||
location / {
|
|
||||||
return 404;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,6 +59,14 @@ let
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
to-server = { server-names, locations, ... }: ''
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name ${toString server-names};
|
||||||
|
${indent (concatStrings (map to-location locations))}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
in
|
in
|
||||||
out
|
out
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user