-
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
79 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 |
---|---|---|
|
@@ -69,16 +69,14 @@ in { | |
forceSSL = true; | ||
useACMEHost = wwwCfg.hostname; | ||
|
||
locations = | ||
{ | ||
"/".extraConfig = '' | ||
include uwsgi_params; | ||
uwsgi_pass unix:${socket}; | ||
''; | ||
|
||
"/static/".alias = "${config.services.searx.package}/share/static"; | ||
} | ||
// wwwCfg.acme-location-block; | ||
locations = { | ||
"/".extraConfig = '' | ||
include uwsgi_params; | ||
uwsgi_pass unix:${socket}; | ||
''; | ||
|
||
"/static/".alias = "${config.services.searx.package}/share/static"; | ||
}; | ||
}; | ||
|
||
redis.servers.searx.user = mkForce config.services.searx.uwsgiConfig.immediate-uid; | ||
|
@@ -96,7 +94,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