summary refs log tree commit diff stats
path: root/modules/webserver.nix
blob: e61cb6879a5960753c37598cb868cee76d4b5dca (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
{ 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 ];
}