feat: added catch all route to reverse proxy that blocks connections on non specified hosts
This commit is contained in:
		
							parent
							
								
									81a6588537
								
							
						
					
					
						commit
						bb5c94ec2c
					
				
					 1 changed files with 19 additions and 1 deletions
				
			
		|  | @ -6,6 +6,11 @@ | |||
|   options.services.reverseProxy = { | ||||
|     enable = lib.mkEnableOption "turn on the reverse proxy"; | ||||
|     openFirewall = lib.mkEnableOption "open the firewall"; | ||||
|     refuseUnmatchedDomains = lib.mkOption { | ||||
|       type = lib.types.bool; | ||||
|       description = "refuse connections for domains that don't match any configured virtual hosts"; | ||||
|       default = true; | ||||
|     }; | ||||
|     ports = { | ||||
|       http = lib.mkOption { | ||||
|         type = lib.types.port; | ||||
|  | @ -96,7 +101,20 @@ | |||
|       services.nginx = { | ||||
|         enable = true; | ||||
|         virtualHosts = lib.mkMerge ( | ||||
|           lib.lists.flatten ( | ||||
|           (lib.optionals config.services.reverseProxy.refuseUnmatchedDomains [ | ||||
|             { | ||||
|               "_" = { | ||||
|                 default = true; | ||||
|                 serverName = "_"; | ||||
|                 locations."/" = { | ||||
|                   extraConfig = '' | ||||
|                     return 444; | ||||
|                   ''; | ||||
|                 }; | ||||
|               }; | ||||
|             } | ||||
|           ]) | ||||
|           ++ lib.lists.flatten ( | ||||
|             lib.attrsets.mapAttrsToList ( | ||||
|               name: service: let | ||||
|                 hostConfig = { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue