-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed fermi configuration for deployment
- Loading branch information
Showing
6 changed files
with
136 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,15 @@ in { | |
type = lib.types.str; | ||
}; | ||
|
||
ip = mkOption { | ||
default = ""; | ||
type = lib.types.str; | ||
}; | ||
ipv6 = mkOption { | ||
default = ""; | ||
type = lib.types.str; | ||
}; | ||
|
||
root = mkOption { | ||
default = "/srv"; | ||
type = lib.types.str; | ||
|
@@ -34,16 +43,10 @@ in { | |
type = lib.types.str; | ||
}; | ||
|
||
acme-location-block = mkOption { | ||
default = { | ||
"^~ /.well-known/acme-challenge".extraConfig = '' | ||
location ^~ /.well-known/acme-challenge/ { | ||
default_type "text/plain"; | ||
root ${cfg.root}/acme; | ||
} | ||
''; | ||
}; | ||
readOnly = true; | ||
keys = mkOption { | ||
default = [ | ||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMmFgG1EuQDoJb8pQcxnhjqbncrpJGZ3iNon/gu0bXiE [email protected]" | ||
]; | ||
}; | ||
}; | ||
|
||
|
@@ -54,26 +57,66 @@ in { | |
password = ""; | ||
shell = "/run/current-system/sw/bin/nologin"; | ||
isSystemUser = true; | ||
home = cfg.root; | ||
openssh.authorizedKeys.keys = cfg.keys; | ||
}; | ||
|
||
groups.${cfg.group} = {}; | ||
}; | ||
|
||
networking.firewall = { | ||
allowedTCPPorts = [80 443]; | ||
allowedUDPPorts = [80 443]; | ||
allowedTCPPorts = [53 80 443]; | ||
allowedUDPPorts = [53 80 443]; | ||
}; | ||
|
||
services.nginx = { | ||
inherit (cfg) user group; | ||
enable = true; | ||
enableReload = true; | ||
services = { | ||
nginx = { | ||
inherit (cfg) user group; | ||
enable = true; | ||
enableReload = true; | ||
|
||
additionalModules = with pkgs.nginxModules; [fancyindex]; | ||
additionalModules = with pkgs.nginxModules; [fancyindex]; | ||
|
||
appendHttpConfig = '' | ||
limit_req_zone $binary_remote_addr zone=put_request_by_addr:20m rate=100r/s; | ||
''; | ||
virtualHosts."auth.${cfg.hostname}" = { | ||
serverName = "auth.${cfg.hostname} www.auth.${cfg.hostname}"; | ||
kTLS = true; | ||
forceSSL = true; | ||
useACMEHost = cfg.hostname; | ||
|
||
locations."/" = { | ||
proxyPass = "http://[::1]:4443/"; | ||
extraConfig = '' | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
''; | ||
}; | ||
}; | ||
|
||
appendHttpConfig = '' | ||
limit_req_zone $binary_remote_addr zone=put_request_by_addr:20m rate=100r/s; | ||
''; | ||
}; | ||
|
||
acme-dns = { | ||
enable = true; | ||
settings = { | ||
api = { | ||
ip = "[::1]"; | ||
port = 4443; | ||
}; | ||
general = rec { | ||
listen = "[::1]:53"; | ||
domain = "auth." + cfg.hostname; | ||
nsname = domain; | ||
nsadmin = "admin." + cfg.hostname; | ||
records = [ | ||
"${nsname}. A ${cfg.ip}" | ||
"${nsname}. AAAA ${cfg.ipv6}" | ||
"${nsname}. NS ${nsname}." | ||
]; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
systemd.tmpfiles.rules = [ | ||
|
@@ -83,14 +126,26 @@ in { | |
|
||
security.acme = { | ||
acceptTerms = true; | ||
|
||
defaults = { | ||
email = "[email protected]"; | ||
webroot = cfg.root + "/acme"; | ||
dnsProvider = "acme-dns"; | ||
environmentFile = pkgs.writeTextFile { | ||
name = "lego-acme-dns.env"; | ||
text = '' | ||
ACME_DNS_API_BASE="http://[::1]:4443" | ||
ACME_DNS_STORAGE_PATH=/var/lib/acme/lego-acme-dns-accounts.json | ||
''; | ||
}; | ||
}; | ||
|
||
certs.${cfg.hostname} = { | ||
inherit (cfg) group; | ||
extraDomainNames = ["www.${cfg.hostname}"]; | ||
extraDomainNames = [ | ||
"www.${cfg.hostname}" | ||
"auth.${cfg.hostname}" | ||
"www.auth.${cfg.hostname}" | ||
]; | ||
}; | ||
}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
inherit (lib.options) mkOption mkEnableOption; | ||
wwwCfg = config.my.www; | ||
cfg = wwwCfg.searx; | ||
socket = "/run/uwsgi/app/searx/socket"; | ||
socket = "/run/uwsgi/socket"; | ||
in { | ||
options.my.www.searx = { | ||
enable = mkEnableOption "searx"; | ||
|
@@ -35,9 +35,7 @@ in { | |
systemd.tmpfiles.rules = let | ||
inherit (config.services.searx.uwsgiConfig) immediate-uid immediate-gid; | ||
in [ | ||
"d /run/uwsgi 0775 ${immediate-uid} ${immediate-gid} -" | ||
"d /run/uwsgi/app 0775 ${immediate-uid} ${immediate-gid} -" | ||
"d /run/uwsgi/app/searx 0775 ${immediate-uid} ${immediate-gid} -" | ||
"d ${builtins.baseNameOf socket} 0775 ${immediate-uid} ${immediate-gid} -" | ||
]; | ||
|
||
environment.etc."nginx/uwsgi_params".text = '' | ||
|
@@ -63,22 +61,19 @@ in { | |
|
||
services = { | ||
nginx.virtualHosts."${cfg.subdomain}.${wwwCfg.hostname}" = { | ||
root = "${config.services.searx.package}/share"; | ||
serverName = "${cfg.subdomain}.${wwwCfg.hostname} www.${cfg.subdomain}.${wwwCfg.hostname}"; | ||
kTLS = true; | ||
forceSSL = true; | ||
useACMEHost = wwwCfg.hostname; | ||
|
||
locations = | ||
{ | ||
"/".extraConfig = '' | ||
include uwsgi_params; | ||
uwsgi_pass unix:${socket}; | ||
''; | ||
locations = { | ||
"/".extraConfig = '' | ||
include uwsgi_params; | ||
uwsgi_pass unix:${socket}; | ||
''; | ||
|
||
"/static/".alias = "${config.services.searx.package}/share/static"; | ||
} | ||
// wwwCfg.acme-location-block; | ||
"/static/".alias = "${config.services.searx.package}/share/static/"; | ||
}; | ||
}; | ||
|
||
redis.servers.searx.user = mkForce config.services.searx.uwsgiConfig.immediate-uid; | ||
|
@@ -96,7 +91,6 @@ in { | |
environmentFile = config.sops.templates."searx.env".path; | ||
|
||
settings = { | ||
use_default_settings = mkForce false; | ||
instance_name = "searx"; | ||
contact_url = "mailto:[email protected]"; | ||
server = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters