diff --git a/web.nix b/web.nix index 6662dc1..c83d22d 100644 --- a/web.nix +++ b/web.nix @@ -25,18 +25,33 @@ services.nginx = { enable = true; - virtualHosts."default" = { - default = true; + recommendedTlsSettings = true; + recommendedProxySettings = true; + recommendedGzipSettings = true; + recommendedOptimisation = true; + + virtualHosts."cordevelop.com" = { + serverAliases = [ "www.cordevelop.com" ]; + enableACME = true; + forceSSL = true; root = "/var/www/html"; locations."/".index = "index.php index.html"; locations."~ \\.php$".extraConfig = '' fastcgi_pass unix:/run/phpfpm/www.sock; - include ${pkgs.nginx}/conf/fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include ${pkgs.nginx}/conf/fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; ''; }; + + # Anything else (bare IP, unknown names) gets no content and no certificate + virtualHosts."_" = { + default = true; + rejectSSL = true; + locations."/".return = "444"; + }; }; + # database "app" and a MySQL user "web" that logs in via the local socket (no password) services.mysql = { ensureDatabases = [ "app" ]; @@ -46,5 +61,5 @@ }]; }; - networking.firewall.allowedTCPPorts = [ 80 ]; + networking.firewall.allowedTCPPorts = [ 80 443 ]; }