-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reverseproxy: do not parse upstream address too early if it contains …
…replaceble parts (#5695) * reverseproxy: do not parse upstream address too early if it contains replaceble parts * remove unused method * cleanup * accommodate partially replaceable port
- Loading branch information
1 parent
9f34383
commit 65e33fc
Showing
7 changed files
with
365 additions
and
40 deletions.
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
caddytest/integration/caddyfile_adapt/replaceable_upstream.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
*.sandbox.localhost { | ||
@sandboxPort { | ||
header_regexp first_label Host ^([0-9]{3})\.sandbox\. | ||
} | ||
handle @sandboxPort { | ||
reverse_proxy {re.first_label.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": "{http.regexp.first_label.1}" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"match": [ | ||
{ | ||
"header_regexp": { | ||
"Host": { | ||
"name": "first_label", | ||
"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 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
caddytest/integration/caddyfile_adapt/replaceable_upstream_partial_port.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
*.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 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
caddytest/integration/caddyfile_adapt/replaceable_upstream_port.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
*.sandbox.localhost { | ||
@sandboxPort { | ||
header_regexp port Host ^([0-9]{3})\.sandbox\. | ||
} | ||
handle @sandboxPort { | ||
reverse_proxy app:{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:{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 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.