caddy/caddytest
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
..
integration caddyhttp: add http.request.local{,.host,.port} placeholder (#6182) 2024-03-27 21:36:53 +00:00
a.caddy.localhost.crt caddyhttp: Add default SNI tests (#3146) 2020-03-17 12:39:01 -06:00
a.caddy.localhost.key caddyhttp: Add default SNI tests (#3146) 2020-03-17 12:39:01 -06:00
caddy.ca.cer httpcaddyfile: Add client_auth options to tls directive (#3335) 2020-06-05 12:19:36 -06:00
caddy.localhost.crt caddyhttp: Fix default SNI for default conn policy (#3141) 2020-03-13 11:32:53 -06:00
caddy.localhost.key caddyhttp: Fix default SNI for default conn policy (#3141) 2020-03-13 11:32:53 -06:00
caddytest.go tests: uses testing.TB interface for helper to be able to use test server in benchmarks. (#6103) 2024-02-20 22:04:14 +00:00
caddytest_test.go caddyhttp: Fix default SNI for default conn policy (#3141) 2020-03-13 11:32:53 -06:00
leafcert.pem caddytls: clientauth: leaf verifier: make trusted leaf certs source pluggable (#6050) 2024-03-05 14:55:37 -07:00