caddy/modules/caddyhttp
Emily ddb1d2c2b1
caddyhttp: add http.request.local{,.host,.port} placeholder (#6182)
* caddyhttp: add `http.request.local{,.host,.port}` placeholder

This is the counterpart of `http.request.remote{,.host,.port}`.

`http.request.remote` operates on the remote client's address, while
`http.request.local` operates on the address the connection arrived on.

Take the following example:

- Caddy serving on `203.0.113.1:80`
- Client on `203.0.113.2`

`http.request.remote.host` would return `203.0.113.2` (client IP)

`http.request.local.host` would return `203.0.113.1` (server IP)
`http.request.local.port` would return `80` (server port)

I find this helpful for debugging setups with multiple servers and/or
multiple network paths (multiple IPs, AnyIP, Anycast).

Co-authored-by: networkException <git@nwex.de>

* caddyhttp: add unit test for `http.request.local{,.host,.port}`

* caddyhttp: add integration test for `http.request.local.port`

* caddyhttp: fix `http.request.local.host` placeholder handling with unix sockets

The implementation matches the one of `http.request.remote.host` now and
returns the unix socket path (just like `http.request.local` already did)
instead of an empty string.

---------

Co-authored-by: networkException <git@nwex.de>
2024-03-27 21:36:53 +00:00
..
caddyauth caddyauth: Drop support for scrypt (#6091) 2024-02-12 19:33:54 +00:00
encode chore: encode: use FlushError instead of Flush (#6168) 2024-03-10 23:04:35 -04:00
fileserver caddyhttp: upgrade to cel v0.20.0 (#6161) 2024-03-13 21:32:42 -06:00
headers caddyhttp: Allow header replacement with empty string (#6163) 2024-03-21 17:29:32 +00:00
logging logging: Implement log_append handler (#6066) 2024-03-05 17:03:59 -07:00
map caddyfile: Normalize & flatten all unmarshalers (#6037) 2024-01-23 19:36:59 -05:00
proxyprotocol caddyfile: Normalize & flatten all unmarshalers (#6037) 2024-01-23 19:36:59 -05:00
push caddyhttp: Allow header replacement with empty string (#6163) 2024-03-21 17:29:32 +00:00
requestbody caddyfile: Normalize & flatten all unmarshalers (#6037) 2024-01-23 19:36:59 -05:00
reverseproxy caddyhttp: Allow header replacement with empty string (#6163) 2024-03-21 17:29:32 +00:00
rewrite Added a null check to avoid segfault on rewrite query ops (#6191) 2024-03-23 01:51:34 -04:00
standard logging: Implement log_append handler (#6066) 2024-03-05 17:03:59 -07:00
templates chore: remove repetitive word (#6193) 2024-03-25 09:05:45 -06:00
tracing caddyfile: Normalize & flatten all unmarshalers (#6037) 2024-01-23 19:36:59 -05:00
app.go caddyhttp: add http.request.local{,.host,.port} placeholder (#6182) 2024-03-27 21:36:53 +00:00
autohttps.go ci: use gci linter (#5708) 2023-08-14 09:41:15 -06:00
caddyhttp_test.go caddyhttp: Test cases for %2F and %252F (#6084) 2024-02-07 05:13:17 -05:00
caddyhttp.go ci: Use gofumpt to format code (#5707) 2023-08-07 19:40:31 +00:00
celmatcher_test.go matchers: Drop forwarded option from remote_ip matcher (#6085) 2024-02-07 10:09:29 -05:00
celmatcher.go caddyhttp: upgrade to cel v0.20.0 (#6161) 2024-03-13 21:32:42 -06:00
errors.go caddyhttp: Preserve original error (fix #5652) 2023-07-25 09:41:56 -06:00
http2listener.go caddyhttp: Serve http2 when listener wrapper doesn't return *tls.Conn (#4929) 2023-04-10 17:05:02 +00:00
httpredirectlistener.go httpredirectlistener: Only set read limit for when request is HTTP (#5917) 2023-11-20 12:31:36 +00:00
invoke.go caddyhttp: Implement named routes, invoke directive (#5107) 2023-05-16 15:27:52 +00:00
ip_matchers.go matchers: Drop forwarded option from remote_ip matcher (#6085) 2024-02-07 10:09:29 -05:00
ip_range.go caddyhttp: Pluggable trusted proxy IP range sources (#5328) 2023-02-06 12:44:11 -07:00
logging.go logging: Implement log_append handler (#6066) 2024-03-05 17:03:59 -07:00
marshalers.go caddyhttp: Fix panic when request missing ClientIPVarKey (#6040) 2024-01-24 00:45:50 +00:00
matchers_test.go matchers: query now ANDs multiple keys (#6054) 2024-01-22 02:36:44 +00:00
matchers.go caddyfile: Normalize & flatten all unmarshalers (#6037) 2024-01-23 19:36:59 -05:00
metrics_test.go metrics: Record request metrics on HTTP errors (#5979) 2023-12-15 20:14:00 +00:00
metrics.go metrics: Record request metrics on HTTP errors (#5979) 2023-12-15 20:14:00 +00:00
replacer_test.go caddyhttp: add http.request.local{,.host,.port} placeholder (#6182) 2024-03-27 21:36:53 +00:00
replacer.go caddyhttp: add http.request.local{,.host,.port} placeholder (#6182) 2024-03-27 21:36:53 +00:00
responsematchers_test.go reverseproxy: Add handle_response blocks to reverse_proxy (#3710) (#4021) 2021-05-02 12:39:06 -06:00
responsematchers.go caddyfile: Normalize & flatten all unmarshalers (#6037) 2024-01-23 19:36:59 -05:00
responsewriter_test.go caddyhttp: Impl ResponseWriter.Unwrap(), prep for Go 1.20's ResponseController (#5509) 2023-04-26 19:44:01 -04:00
responsewriter.go caddyhttp: suppress flushing if the response is being buffered (#6150) 2024-03-11 20:03:20 +00:00
routes.go caddyhttp: Implement named routes, invoke directive (#5107) 2023-05-16 15:27:52 +00:00
server_test.go caddyhttp: Accept XFF header values with ports, when parsing client IP (#6183) 2024-03-21 10:54:25 -06:00
server.go chore: Update quic-go to v0.42.0 (#6176) 2024-03-21 10:56:10 -06:00
staticerror.go caddyfile: Normalize & flatten all unmarshalers (#6037) 2024-01-23 19:36:59 -05:00
staticresp_test.go Move from deprecated ioutil to os and io packages (#4364) 2021-09-29 11:17:48 -06:00
staticresp.go caddyfile: Normalize & flatten all unmarshalers (#6037) 2024-01-23 19:36:59 -05:00
subroute.go reverseproxy: Enable changing only the status code (close #2920) 2020-06-04 12:06:38 -06:00
vars.go vars: Make nil values act as empty string instead of "<nil>" (#6174) 2024-03-21 11:21:53 -06:00