blob: ac95ddf98dbffc2e54fa068cb4a48f5f46f60625 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
{ config, libs, pkgs, ... }:
{
users.users.nginx.extraGroups = [ "acme" ];
services.nginx = {
enable = true;
virtualHosts = {
"krinitsin.com" = {
forceSSL = true;
enableACME = true;
root = "/var/www/krinitsin.com";
serverAliases = [ "www.krinitsin.com" ];
locations."/shopping/".basicAuthFile = "/secret/shopping_auth";
locations."/shopping/api/" = {
proxyPass = "http://127.0.0.1:5000";
basicAuthFile = "/secret/shopping_auth";
};
locations."/mensa/api/".proxyPass = "http://127.0.0.1:5000";
};
};
};
security.acme = {
acceptTerms = true;
defaults.email = "christian@krinitsin.xyz";
};
systemd.services.flask-backend = {
enable = true;
wantedBy = ["multi-user.target"];
serviceConfig.ExecStart = ''/var/flask-backend/result/bin/app.py'';
};
networking.firewall.allowedTCPPorts = [ 80 443 5000 ];
services.monit.config = ''
check process nginx with pidfile /var/run/nginx/nginx.pid
start program = "${pkgs.systemd}/bin/systemctl start nginx"
stop program = "${pkgs.systemd}/bin/systemctl stop nginx"
if failed host 127.0.0.1 port 443 then restart
'';
}
|