From 4cc39850b9512115acbeaf52afea319af3c6c535 Mon Sep 17 00:00:00 2001 From: coolneng Date: Tue, 11 May 2021 13:56:04 +0200 Subject: [PATCH] Move each Mono web app into its own subdomain --- modules/webstack.nix | 61 ++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/modules/webstack.nix b/modules/webstack.nix index 1d9a4df..3940ad2 100644 --- a/modules/webstack.nix +++ b/modules/webstack.nix @@ -43,28 +43,31 @@ }; }; virtualHosts = { - "frontend.coace.duckdns.org" = { + "gcw.coace.duckdns.org" = { enableACME = true; forceSSL = true; - root = "/vault/backups/frontend/inetpub/wwwroot"; - locations = { - "/few/".extraConfig = '' - fastcgi_index Default.aspx; - fastcgi_pass 127.0.0.1:9000; - fastcgi_param SCRIPT_FILENAME $document_root/few/$fastcgi_script_name; - fastcgi_param PATH_INFO ""; - fastcgi-mono-server4 /applications=/few/:/vault/backups/frontend/inetpub/wwwroot/few/socket=tcp:127.0.0.1:9000; - include ${pkgs.nginx}/conf/fastcgi_params; - ''; - "/gcw/".extraConfig = '' - fastcgi_index Default.aspx; - fastcgi_pass 127.0.0.1:9000; - fastcgi_param SCRIPT_FILENAME $document_root/few/$fastcgi_script_name; - fastcgi_param PATH_INFO ""; - fastcgi-mono-server4 /applications=/gcw/:/vault/backups/frontend/inetpub/wwwroot/gcw/socket=tcp:127.0.0.1:9000; - include ${pkgs.nginx}/conf/fastcgi_params; - ''; - }; + root = "/vault/backups/frontend/inetpub/wwwroot/gcw"; + locations."/".extraConfig = '' + fastcgi_index Default.aspx; + fastcgi_pass 127.0.0.1:9000; + fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; + fastcgi_param PATH_INFO ""; + fastcgi-mono-server4 /applications=gcw.coace.duckns.org/:/vault/backups/frontend/inetpub/wwwroot/gcw/socket=tcp:127.0.0.1:9001; + include ${pkgs.nginx}/conf/fastcgi_params; + ''; + }; + "few.coace.duckdns.org" = { + enableACME = true; + forceSSL = true; + root = "/vault/backups/frontend/inetpub/wwwroot/few"; + locations."/".extraConfig = '' + fastcgi_index Default.aspx; + fastcgi_pass 127.0.0.1:9001; + fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; + fastcgi_param PATH_INFO ""; + fastcgi-mono-server4 /applications=few.coace.duckdns.org/:/vault/backups/frontend/inetpub/wwwroot/few/socket=tcp:127.0.0.1:9001; + include ${pkgs.nginx}/conf/fastcgi_params; + ''; }; }; }; @@ -75,7 +78,7 @@ email = "secretario@arquitectosdeceuta.com"; certs."coace.duckdns.org" = { webroot = "/var/lib/acme/acme-challenge"; - extraDomainNames = [ "frontend.coace.duckdns.org" ]; + extraDomainNames = [ "few.coace.duckdns.org" "gcw.coace.duckdns.org" ]; }; }; @@ -103,19 +106,11 @@ wantedBy = [ "default.target" ]; path = with pkgs; [ mono6 ]; script = '' - lockfile=/tmp/mono-service - ${pkgs.mono6}/bin/mono-service -d:/vault/backups/frontend/inetpub/wwwroot/gcw -l:$lockfile - ${pkgs.mono6}/bin/mono-service -d:/vault/backups/frontend/inetpub/wwwroot/few -l:$lockfile + gcw_lockfile=/tmp/mono-service-gcw + few_lockfile=/tmp/mono-service-few + ${pkgs.mono6}/bin/mono-service --applications /:/vault/backups/frontend/inetpub/wwwroot/gcw -l:$gcw_lockfile --socket=tcp:127.0.0.1:9000 + ${pkgs.mono6}/bin/mono-service --applications /:/vault/backups/frontend/inetpub/wwwroot/few -l:$few_lockfile --socket=tcp:127.0.0.1:9001 ''; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = "yes"; - User = "nginx"; - Group = "nginx"; - ExecStop = '' - kill `cat $lockfile` - ''; - }; before = [ "nginx.service" ]; }; }