mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-10-30 18:22:49 -04:00 
			
		
		
		
	* reverseproxy: do not parse upstream address too early if it contains replaceble parts * remove unused method * cleanup * accommodate partially replaceable port
		
			
				
	
	
		
			100 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			100 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| *.sandbox.localhost {
 | |
| 	@sandboxPort {
 | |
| 		header_regexp port Host ^([0-9]{3})\.sandbox\.
 | |
| 	}
 | |
| 	handle @sandboxPort {
 | |
| 		reverse_proxy app:6{re.port.1}
 | |
| 	}
 | |
| 	handle {
 | |
| 		redir {scheme}://application.localhost
 | |
| 	}
 | |
| }
 | |
| 
 | |
| ----------
 | |
| {
 | |
| 	"apps": {
 | |
| 		"http": {
 | |
| 			"servers": {
 | |
| 				"srv0": {
 | |
| 					"listen": [
 | |
| 						":443"
 | |
| 					],
 | |
| 					"routes": [
 | |
| 						{
 | |
| 							"match": [
 | |
| 								{
 | |
| 									"host": [
 | |
| 										"*.sandbox.localhost"
 | |
| 									]
 | |
| 								}
 | |
| 							],
 | |
| 							"handle": [
 | |
| 								{
 | |
| 									"handler": "subroute",
 | |
| 									"routes": [
 | |
| 										{
 | |
| 											"group": "group2",
 | |
| 											"handle": [
 | |
| 												{
 | |
| 													"handler": "subroute",
 | |
| 													"routes": [
 | |
| 														{
 | |
| 															"handle": [
 | |
| 																{
 | |
| 																	"handler": "reverse_proxy",
 | |
| 																	"upstreams": [
 | |
| 																		{
 | |
| 																			"dial": "app:6{http.regexp.port.1}"
 | |
| 																		}
 | |
| 																	]
 | |
| 																}
 | |
| 															]
 | |
| 														}
 | |
| 													]
 | |
| 												}
 | |
| 											],
 | |
| 											"match": [
 | |
| 												{
 | |
| 													"header_regexp": {
 | |
| 														"Host": {
 | |
| 															"name": "port",
 | |
| 															"pattern": "^([0-9]{3})\\.sandbox\\."
 | |
| 														}
 | |
| 													}
 | |
| 												}
 | |
| 											]
 | |
| 										},
 | |
| 										{
 | |
| 											"group": "group2",
 | |
| 											"handle": [
 | |
| 												{
 | |
| 													"handler": "subroute",
 | |
| 													"routes": [
 | |
| 														{
 | |
| 															"handle": [
 | |
| 																{
 | |
| 																	"handler": "static_response",
 | |
| 																	"headers": {
 | |
| 																		"Location": [
 | |
| 																			"{http.request.scheme}://application.localhost"
 | |
| 																		]
 | |
| 																	},
 | |
| 																	"status_code": 302
 | |
| 																}
 | |
| 															]
 | |
| 														}
 | |
| 													]
 | |
| 												}
 | |
| 											]
 | |
| 										}
 | |
| 									]
 | |
| 								}
 | |
| 							],
 | |
| 							"terminal": true
 | |
| 						}
 | |
| 					]
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 	}
 | |
| } |