vpsConfig

my VPS configuration deployed through nixosAnywhere
Log | Files | Refs

websites.nix (1175B)


      1 # a container that hosts the websites on my VPS
      2 { pkgs, ... }: {
      3   containers.websites = {
      4     autoStart = true;
      5     privateNetwork = true;
      6     hostAddress = "10.100.0.1";
      7     localAddress = "10.100.0.3";
      8     forwardPorts = [
      9       { hostPort = 80; containerPort = 80; }
     10       { hostPort = 443; containerPort = 443; }
     11     ];
     12 
     13     config = {
     14       system.stateVersion = "24.05";
     15 
     16       programs.nano.enable = false;
     17       programs.vim.defaultEditor = true;
     18 
     19       environment.systemPackages = with pkgs; [
     20 	git
     21       ];
     22 
     23       services.nginx = {
     24 	enable = true;
     25 	virtualHosts = {
     26 	  "_" = {
     27 	    default =true;
     28 	    locations."/" = {
     29 	      root = "/var/www/default";
     30 	    };
     31 	  };
     32 
     33 	  "fedorvin.com" = {
     34 	    enableACME = true;
     35 	    forceSSL = true;
     36 	    root = "/var/www/fedorvin";
     37             locations."/" = {
     38 	      tryFiles = "$uri $uri/ =404";
     39 	    };
     40 	    locations."~* \\.(css|js|png|jpg|jpeg|gif|ico)$" = {
     41 	      extraConfig = ''
     42 		expires max;
     43 		log_not_found off;
     44 	      '';
     45 	    };
     46 	  };
     47 	};
     48       };
     49 
     50       security.acme = {
     51 	acceptTerms = true;
     52 	defaults.email = "vino-f@pm.me";
     53       };
     54 
     55       networking.firewall.allowedTCPPorts = [ 80 443 ];
     56 
     57     };
     58   };
     59 }