mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-11-03 19:17:29 -05:00 
			
		
		
		
	httpcaddyfile: Fix ordering of catch-all site blocks
Catch-alls should always go last. Normally this is the case, but we have a special case for comparing one wildcard-host site block to another non-wildcard host site block; and a catch-all site block is also a non-wildcard host site block, so now we have to special-case the catch-all site block. Sigh. This could be reproduced with a Caddyfile that has two site blocks: ":80" and "*.example.com", in that order.
This commit is contained in:
		
							parent
							
								
									003403ecbc
								
							
						
					
					
						commit
						32cafbb630
					
				@ -400,6 +400,11 @@ func (st *ServerType) serversFromPairings(
 | 
				
			|||||||
					jLongestPath = addr.Path
 | 
										jLongestPath = addr.Path
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								if specificity(jLongestHost) == 0 {
 | 
				
			||||||
 | 
									// catch-all blocks (blocks with no hostname) should always go
 | 
				
			||||||
 | 
									// last, even after blocks with wildcard hosts
 | 
				
			||||||
 | 
									return true
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			if iWildcardHost != jWildcardHost {
 | 
								if iWildcardHost != jWildcardHost {
 | 
				
			||||||
				// site blocks that have a key with a wildcard in the hostname
 | 
									// site blocks that have a key with a wildcard in the hostname
 | 
				
			||||||
				// must always be less specific than blocks without one; see
 | 
									// must always be less specific than blocks without one; see
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user