-
-
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.
httpcaddyfile: Refactor to allow named matchers in
route
blocks
- Loading branch information
1 parent
904f149
commit 0a64524
Showing
3 changed files
with
161 additions
and
30 deletions.
There are no files selected for viewing
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
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
132 changes: 132 additions & 0 deletions
132
caddytest/integration/caddyfile_adapt/php_fastcgi_expanded_form.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,132 @@ | ||
:8886 | ||
|
||
route { | ||
# Add trailing slash for directory requests | ||
@canonicalPath { | ||
file { | ||
try_files {path}/index.php | ||
} | ||
not path */ | ||
} | ||
redir @canonicalPath {path}/ 308 | ||
|
||
# If the requested file does not exist, try index files | ||
@indexFiles { | ||
file { | ||
try_files {path} {path}/index.php index.php | ||
split_path .php | ||
} | ||
} | ||
rewrite @indexFiles {http.matchers.file.relative} | ||
|
||
# Proxy PHP files to the FastCGI responder | ||
@phpFiles { | ||
path *.php | ||
} | ||
reverse_proxy @phpFiles 127.0.0.1:9000 { | ||
transport fastcgi { | ||
split .php | ||
} | ||
} | ||
} | ||
---------- | ||
{ | ||
"apps": { | ||
"http": { | ||
"servers": { | ||
"srv0": { | ||
"listen": [ | ||
":8886" | ||
], | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"handler": "subroute", | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"handler": "static_response", | ||
"headers": { | ||
"Location": [ | ||
"{http.request.uri.path}/" | ||
] | ||
}, | ||
"status_code": 308 | ||
} | ||
], | ||
"match": [ | ||
{ | ||
"file": { | ||
"try_files": [ | ||
"{http.request.uri.path}/index.php" | ||
] | ||
}, | ||
"not": [ | ||
{ | ||
"path": [ | ||
"*/" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"handle": [ | ||
{ | ||
"handler": "rewrite", | ||
"uri": "{http.matchers.file.relative}" | ||
} | ||
], | ||
"match": [ | ||
{ | ||
"file": { | ||
"split_path": [ | ||
".php" | ||
], | ||
"try_files": [ | ||
"{http.request.uri.path}", | ||
"{http.request.uri.path}/index.php", | ||
"index.php" | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"handle": [ | ||
{ | ||
"handler": "reverse_proxy", | ||
"transport": { | ||
"protocol": "fastcgi", | ||
"split_path": [ | ||
".php" | ||
] | ||
}, | ||
"upstreams": [ | ||
{ | ||
"dial": "127.0.0.1:9000" | ||
} | ||
] | ||
} | ||
], | ||
"match": [ | ||
{ | ||
"path": [ | ||
"*.php" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} |