caddy/modules/caddyhttp
Matthew Holt fbd6560976
fileserver: Only redirect if filename not rewritten (fix #4205)
This is the more correct implementation of  23dadc0d86 (#4179)... I think. This commit effectively undoes the revert in 8848df9c5d, but with corrections to the logic.

We *do* need to use the original request path (the path the browser knows) for redirects, since they are external, and rewrites are only internal.

However, if the path was rewritten to a non-canonical path, we should not redirect to canonicalize that, since rewrites are intentional by the site owner. Canonicalizing the path involves modifying only the suffix (base element, or filename) of the path. Thus, if a rewrite involves only the prefix (like how handle_path strips a path prefix), then we can (hopefully!) safely redirect using the original URI since the filename was not rewritten.

So basically, if rewrites modify the filename, we should not canonicalize those requests. If rewrites only modify another part of the path (commonly a prefix), we should be OK to redirect.
2021-06-17 09:55:49 -06:00
..
caddyauth go.mod: Migrate to golang.org/x/term (#4073) 2021-03-29 12:39:08 -06:00
encode encode: Drop prefer from Caddyfile (#4156) 2021-05-10 11:12:59 -06:00
fileserver fileserver: Only redirect if filename not rewritten (fix #4205) 2021-06-17 09:55:49 -06:00
headers headers: Fix Caddyfile parsing for request_header with matchers (#4085) 2021-03-29 10:55:29 -06:00
map map: Accept regex substitution in outputs (#3991) 2021-03-10 14:22:33 -07:00
push headers: Support default header values in Caddyfile with '?' (#3807) 2020-11-20 12:38:16 -07:00
requestbody Revert "requestbody: Allow overwriting remote address" 2021-01-19 18:43:01 -07:00
reverseproxy Some misc. cleanup 2021-06-16 14:29:42 -06:00
rewrite rewrite: Implement regex path replacements 2021-03-01 18:27:59 -07:00
standard encode,staticfiles: Content negotiation, precompressed files (#4045) 2021-03-29 18:47:19 -06:00
templates fileserver: Share template logic for both templates and file_server browse (#4093) 2021-04-30 22:17:23 -04:00
app.go reverseproxy: Add duration/latency placeholders (close #4012) (#4013) 2021-02-22 11:57:21 -07:00
autohttps.go caddyhttp: Implement better logic for inserting the HTTP->HTTPS redirs (#4033) 2021-04-19 19:54:12 -06:00
caddyhttp.go httpcaddyfile: Configure servers via global options (#3836) 2020-11-23 12:46:50 -07:00
celmatcher_test.go caddyhttp: Add support to resolve DN in CEL expression (#3608) 2020-07-31 15:06:30 -06:00
celmatcher.go go.mod: Update direct dependencies 2021-06-03 12:18:25 -06:00
errors.go ci: Use golangci's github action for linting (#3794) 2020-11-22 14:50:29 -07:00
marshalers.go ci: Use golangci's github action for linting (#3794) 2020-11-22 14:50:29 -07:00
matchers_test.go reverseproxy: Add handle_response blocks to reverse_proxy (#3710) (#4021) 2021-05-02 12:39:06 -06:00
matchers.go reverseproxy: Add handle_response blocks to reverse_proxy (#3710) (#4021) 2021-05-02 12:39:06 -06:00
metrics_test.go metrics: Fix panic when headers aren't written (#3737) 2020-09-21 13:42:47 -06:00
metrics.go metrics: Always track method label in uppercase (#3742) 2020-09-22 20:10:34 -06:00
replacer_test.go caddyfile: Fix caddy fmt nesting not decrementing (#4157) 2021-05-10 12:01:27 -06:00
replacer.go reverseproxy: Add duration/latency placeholders (close #4012) (#4013) 2021-02-22 11:57:21 -07:00
responsematchers_test.go reverseproxy: Add handle_response blocks to reverse_proxy (#3710) (#4021) 2021-05-02 12:39:06 -06:00
responsematchers.go reverseproxy: Add handle_response blocks to reverse_proxy (#3710) (#4021) 2021-05-02 12:39:06 -06:00
responsewriter.go caddyhttp: Fix trailers when recording responses (fixes #3236) 2020-04-22 11:10:13 -06:00
routes.go caddyhttp: Fix fallback for the error handler chain (#4131) 2021-05-05 15:55:40 -06:00
server.go caddyhttp: Implement better logic for inserting the HTTP->HTTPS redirs (#4033) 2021-04-19 19:54:12 -06:00
staticerror.go httpcaddyfile: Add error directive for the existing handler (#4034) 2021-03-12 13:25:49 -07:00
staticresp_test.go Implement config adapters and beginning of Caddyfile adapter 2019-08-09 12:05:47 -06:00
staticresp.go caddyhttp: Check for invalid subdirectives of static_response 2021-02-02 16:19:58 -07:00
subroute.go reverseproxy: Enable changing only the status code (close #2920) 2020-06-04 12:06:38 -06:00
vars.go caddyfile: Add support for vars and vars_regexp matchers (#3730) 2020-09-25 17:50:26 -06:00