f4bf4e0097
perf: use zap's Check() to prevent useless allocs ( #6560 )
...
* perf: use zap's Check() to prevent useless allocs
* fix
* fix
* fix
* fix
* restore previous replacer behavior
* fix linter
2024-09-13 11:16:37 -06:00
c050a37e1c
reverse_proxy: add placeholder http.reverse_proxy.retries ( #6553 )
...
Tests / test (./cmd/caddy/caddy, ~1.22.3, ubuntu-latest, 0, 1.22, linux) (push) Has been cancelled
Tests / test (./cmd/caddy/caddy, ~1.23.0, macos-14, 0, 1.23, mac) (push) Has been cancelled
Tests / test (./cmd/caddy/caddy, ~1.23.0, ubuntu-latest, 0, 1.23, linux) (push) Has been cancelled
Tests / test (./cmd/caddy/caddy.exe, ~1.22.3, windows-latest, True, 1.22, windows) (push) Has been cancelled
Tests / test (./cmd/caddy/caddy.exe, ~1.23.0, windows-latest, True, 1.23, windows) (push) Has been cancelled
Tests / test (s390x on IBM Z) (push) Has been cancelled
Cross-Build / build (~1.22.3, 1.22, aix) (push) Has been cancelled
Cross-Build / build (~1.22.3, 1.22, darwin) (push) Has been cancelled
Cross-Build / build (~1.22.3, 1.22, dragonfly) (push) Has been cancelled
Cross-Build / build (~1.22.3, 1.22, freebsd) (push) Has been cancelled
Cross-Build / build (~1.22.3, 1.22, illumos) (push) Has been cancelled
Cross-Build / build (~1.22.3, 1.22, linux) (push) Has been cancelled
Cross-Build / build (~1.22.3, 1.22, netbsd) (push) Has been cancelled
Cross-Build / build (~1.22.3, 1.22, openbsd) (push) Has been cancelled
Cross-Build / build (~1.22.3, 1.22, solaris) (push) Has been cancelled
Cross-Build / build (~1.22.3, 1.22, windows) (push) Has been cancelled
Cross-Build / build (~1.23.0, 1.23, aix) (push) Has been cancelled
Cross-Build / build (~1.23.0, 1.23, darwin) (push) Has been cancelled
Cross-Build / build (~1.23.0, 1.23, dragonfly) (push) Has been cancelled
Cross-Build / build (~1.23.0, 1.23, freebsd) (push) Has been cancelled
Cross-Build / build (~1.23.0, 1.23, illumos) (push) Has been cancelled
Cross-Build / build (~1.23.0, 1.23, linux) (push) Has been cancelled
Cross-Build / build (~1.23.0, 1.23, netbsd) (push) Has been cancelled
Cross-Build / build (~1.23.0, 1.23, openbsd) (push) Has been cancelled
Cross-Build / build (~1.23.0, 1.23, solaris) (push) Has been cancelled
Cross-Build / build (~1.23.0, 1.23, windows) (push) Has been cancelled
Lint / lint (macos-14, mac) (push) Has been cancelled
Lint / lint (ubuntu-latest, linux) (push) Has been cancelled
Lint / lint (windows-latest, windows) (push) Has been cancelled
Lint / govulncheck (push) Has been cancelled
* Add placeholder http.reverse_proxy.lb.retries
* Renamed placeholder to http.reverse_proxy.retries
2024-08-30 11:53:56 -06:00
2bb2ecc549
reverseproxy: Change errors writing the response to warning. ( #6532 )
...
Tests / test (./cmd/caddy/caddy, ~1.21.0, macos-14, 0, 1.21, mac) (push) Waiting to run
Tests / test (./cmd/caddy/caddy, ~1.21.0, ubuntu-latest, 0, 1.21, linux) (push) Waiting to run
Tests / test (./cmd/caddy/caddy, ~1.22.3, macos-14, 0, 1.22, mac) (push) Waiting to run
Tests / test (./cmd/caddy/caddy, ~1.22.3, ubuntu-latest, 0, 1.22, linux) (push) Waiting to run
Tests / test (./cmd/caddy/caddy.exe, ~1.21.0, windows-latest, True, 1.21, windows) (push) Waiting to run
Tests / test (./cmd/caddy/caddy.exe, ~1.22.3, windows-latest, True, 1.22, windows) (push) Waiting to run
Tests / test (s390x on IBM Z) (push) Waiting to run
Tests / goreleaser-check (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, aix) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, darwin) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, dragonfly) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, freebsd) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, illumos) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, linux) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, netbsd) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, openbsd) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, solaris) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, windows) (push) Waiting to run
Lint / lint (ubuntu-latest, linux) (push) Waiting to run
Lint / lint (windows-latest, windows) (push) Waiting to run
Lint / govulncheck (push) Waiting to run
Lint / lint (macos-14, mac) (push) Waiting to run
Most of the errors that can be seen here are write errors due to clients
aborting the request from their side. Often seen ones include:
* writing: ... write: broken pipe
* writing: ... connection timed out
* writing: http2: stream closed
* writing: timeout...
* writing: h3 error...
Most of these errors are beyond of the control of caddy on the client side,
probably nothing can be done on the server side. It still warrants
researching when these errors occur very often, so a change in level from
error to warn is better here to not polute the logs with errors in the
normal case.
2024-08-21 11:39:20 -06:00
c3fb5f4d3f
caddyhttp: Reject 0-RTT early data in IP matchers and set Early-Data header when proxying ( #6427 )
...
* caddyhttp: Reject 0-RTT early data in IP matchers and set Early-Data header when proxying
See RFC 8470: https://httpwg.org/specs/rfc8470.html
Thanks to Michael Wedl (@MWedl) at the University of Applied Sciences St. Poelten for reporting this.
* Don't return value for {remote} placeholder in early data
* Add Caddyfile support
2024-07-05 10:46:20 -06:00
9f97df2275
reverseproxy: Remove long-deprecated buffering properties
...
They've been deprecated for over a year and we printed warnings during that time.
2024-04-22 15:34:14 -06:00
d93e027e01
reverseproxy: Reuse buffered request body even if partially drained
...
Previous commit only works when the backends don't read any of the body first.
2024-04-22 15:22:50 -06:00
613d544a47
reverseproxy: Accept EOF when buffering
...
Before this change, a read of size (let's say) < 10, into a buffer of size 10, will return EOF because we're using CopyN to limit to the size of the buffer. That resulted in the body being read from later, which should only happen if it couldn't fit in the buffer.
With this change, the body is properly NOT set when it can all fit in the buffer.
2024-04-22 13:12:10 -06:00
b40cacf5ce
reverseproxy: Wait for both ends of websocket to close ( #6175 )
2024-04-15 11:37:37 -06:00
53f7035299
reverseproxy: use context.WithoutCancel ( #6116 )
2024-02-19 20:25:02 -07:00
2fe69a828f
chore: enabling a few more linters ( #5961 )
...
Co-authored-by: Francis Lavoie <lavofr@gmail.com >
2024-01-25 15:24:58 +00:00
d9ff7b1872
reverseproxy: Only change Content-Length when full request is buffered ( #5830 )
...
fixes: https://github.com/caddyserver/caddy/issues/5829
Signed-off-by: Fred Cox <mcfedr@gmail.com >
2024-01-09 12:59:30 -07:00
4de2c1c65e
panic when reading from backend failed to propagate stream error ( #5952 )
2023-11-23 03:18:18 -05:00
3a3182fba3
reverseproxy: Add more debug logs ( #5793 )
...
* reverseproxy: Add more debug logs
This makes debug logging very noisy when reverse proxying, but I guess
that's the point.
This has shown to be useful in troubleshooting infrastructure issues.
* Update modules/caddyhttp/reverseproxy/streaming.go
Co-authored-by: Francis Lavoie <lavofr@gmail.com >
* Update modules/caddyhttp/reverseproxy/streaming.go
Co-authored-by: Francis Lavoie <lavofr@gmail.com >
* Add opt-in `trace_logs` option
* Rename to VerboseLogs
---------
Co-authored-by: Francis Lavoie <lavofr@gmail.com >
2023-10-11 13:36:20 -06:00
2a6859a5e4
reverseproxy: Fix retries on "upstreams unavailable" error ( #5841 )
2023-10-10 22:07:20 +00:00
4feac4d83c
reverseproxy: Allow fallthrough for response handlers without routes ( #5780 )
2023-10-05 23:15:26 -04:00
936ee918ee
reverseproxy: Always return new upstreams ( fix #5736 ) ( #5752 )
...
* reverseproxy: Always return new upstreams (fix #5736 )
* Fix healthcheck logger race
2023-08-17 11:33:40 -06:00
d6f86cccf5
ci: use gci linter ( #5708 )
...
* use gofmput to format code
* use gci to format imports
* reconfigure gci
* linter autofixes
* rearrange imports a little
* export GOOS=windows golangci-lint run ./... --fix
2023-08-14 09:41:15 -06:00
b32f265eca
ci: Use gofumpt to format code ( #5707 )
2023-08-07 19:40:31 +00:00
cd486c25d1
caddyhttp: Make use of http.ResponseController
( #5654 )
...
* caddyhttp: Make use of http.ResponseController
Also syncs the reverseproxy implementation with stdlib's which now uses ResponseController as well 2449bbb5e6
* Enable full-duplex for HTTP/1.1
* Appease linter
* Add warning for builds with Go 1.20, so it's less surprising to users
* Improved godoc for EnableFullDuplex, copied text from stdlib
* Only wrap in encode if not already wrapped
2023-08-02 20:03:26 +00:00
da23501457
reverseproxy: Connection termination cleanup ( #5663 )
2023-08-01 14:01:12 +00:00
f45a6de20d
go.mod: Update quic-go to v0.37.0, bump to Go 1.20 minimum ( #5644 )
...
* update quic-go to v0.37.0
* Bump to Go 1.20
* Bump golangci-lint version, yml syntax consistency
* Use skip-pkg-cache workaround
* Workaround needed for both?
* Seeding weakrand is no longer necessary
---------
Co-authored-by: Matt Holt <mholt@users.noreply.github.com >
Co-authored-by: Francis Lavoie <lavofr@gmail.com >
2023-07-21 22:00:48 -06:00
424ae0f420
reverseproxy: Experimental streaming timeouts ( #5567 )
...
* reverseproxy: WIP streaming timeouts
* More verbose logging by using the child logger
* reverseproxy: Implement streaming timeouts
* reverseproxy: Refactor cleanup
* reverseproxy: Avoid **time.Timer
---------
Co-authored-by: Francis Lavoie <lavofr@gmail.com >
2023-06-19 15:54:43 -06:00
2ddb717144
reverseproxy: Fix parsing of source IP in case it's an ipv6 address ( #5569 )
2023-06-12 09:35:22 -06:00
335cd2e8a4
reverseproxy: Fix active health check header canonicalization, refactor ( #5446 )
2023-05-05 15:19:22 -06:00
4636109ce1
reverseproxy: Remove deprecated lookup_srv
( #5396 )
2023-04-10 20:08:40 +00:00
b6fe5d4b41
proxyprotocol: Add PROXY protocol support to reverse_proxy
, add HTTP listener wrapper ( #5424 )
...
Co-authored-by: WeidiDeng <weidi_deng@icloud.com >
Co-authored-by: Francis Lavoie <lavofr@gmail.com >
2023-03-31 17:44:53 -04:00
2182270a2c
reverseproxy: Reset Content-Length to prevent FastCGI from hanging ( #5435 )
...
Fixes: https://github.com/caddyserver/caddy/issues/5420
2023-03-16 11:42:16 -06:00
4b119a475f
reverseproxy: Don't buffer chunked requests ( fix #5366 ) ( #5367 )
...
* reverseproxy: Don't buffer chunked requests (fix #5366 )
Mostly reverts 845bc4d50b437995d574819850206e4b3db4040d (#5289 )
Adds warning for unsafe config.
Deprecates unsafe properties in favor of simpler, safer designed ones.
* Update modules/caddyhttp/reverseproxy/caddyfile.go
Co-authored-by: Y.Horie <u5.horie@gmail.com >
* Update modules/caddyhttp/reverseproxy/reverseproxy.go
Co-authored-by: Y.Horie <u5.horie@gmail.com >
* Update modules/caddyhttp/reverseproxy/reverseproxy.go
Co-authored-by: Y.Horie <u5.horie@gmail.com >
* Remove unused code
---------
Co-authored-by: Y.Horie <u5.horie@gmail.com >
2023-02-11 17:25:29 -07:00
223cbe3d0b
caddyhttp: Add server-level trusted_proxies
config ( #5103 )
2023-01-10 00:08:23 -05:00
845bc4d50b
reverseproxy: Fix hanging for Transfer-Encoding: chunked ( #5289 )
...
* Fixes #5236
* enable request body buffering in reverse proxy
when the request header has Transfer-Encoding: chunked
2023-01-09 00:13:34 -07:00
fcdbc69fab
Fix comment
...
I apparently read the diff backwards in
2a8c458ffedf886af9542541ea1b1de62370929d
2022-09-29 12:38:36 -06:00
2a8c458ffe
reverseproxy: Parse humanized byte size ( fix #5095 )
2022-09-29 12:37:06 -06:00
e2991eb019
reverseproxy: On 103 don't delete own headers ( #5091 )
...
See #5074
2022-09-29 08:19:56 -06:00
e43b6d8178
core: Variadic Context.Logger(); soft deprecation
...
Ideally I'd just remove the parameter to caddy.Context.Logger(), but
this would break most Caddy plugins.
Instead, I'm making it variadic and marking it as partially deprecated.
In the future, I might completely remove the parameter once most
plugins have updated.
2022-09-16 16:55:36 -06:00
66476d8c8f
reverseproxy: Close hijacked conns on reload/quit ( #4895 )
...
* reverseproxy: Close hijacked conns on reload/quit
We also send a Close control message to both ends of
WebSocket connections. I have tested this many times in
my dev environment with consistent success, although
the variety of scenarios was limited.
* Oops... actually call Close() this time
* CloseMessage --> closeMessage
Co-authored-by: Francis Lavoie <lavofr@gmail.com >
* Use httpguts, duh
* Use map instead of sync.Map
Co-authored-by: Francis Lavoie <lavofr@gmail.com >
2022-09-02 17:01:55 -06:00
d4d8bbcfc6
events: Implement event system ( #4912 )
...
Co-authored-by: Matt Holt <mholt@users.noreply.github.com >
2022-08-31 15:01:30 -06:00
8cb3cf540c
Minor cleanup, resolve a couple lint warnings
2022-08-29 12:31:56 -06:00
e1801fdb19
Remove duplicate words in comments ( #4986 )
2022-08-27 14:39:26 -06:00
0c57facc67
reverseproxy: Add upstreams healthy metrics ( #4935 )
2022-08-27 12:30:23 -06:00
c7772588bd
core: Change net.IP to netip.Addr; use netip.Prefix ( #4966 )
...
Co-authored-by: Matt Holt <mholt@users.noreply.github.com >
2022-08-17 16:10:57 -06:00
f5dce84a70
reverseproxy: Ignore context cancel in stream mode ( #4952 )
2022-08-12 13:15:41 -06:00
085df25c7e
reverseproxy: Support 1xx status codes (HTTP early hints) ( #4882 )
2022-08-09 10:53:24 -06:00
d26559316f
Replace strings.Index with strings.Cut ( #4932 )
2022-08-06 22:03:37 -06:00
141872ed80
chore: Bump up to Go 1.19, minimum 1.18 ( #4925 )
2022-08-02 16:39:09 -04:00
7d1f7771c9
reverseproxy: Implement retry count, alternative to try_duration ( #4756 )
...
* reverseproxy: Implement retry count, alternative to try_duration
* Add Caddyfile support for `retry_match`
* Refactor to deduplicate matcher parsing logic
* Fix lint
2022-07-13 14:15:00 -06:00
d6bc9e0b5c
reverseproxy: Err 503 if all upstreams unavailable
2022-07-08 13:01:32 -06:00
98468af8b6
reverseproxy: Fix double headers in response handlers ( #4847 )
2022-06-22 15:10:14 -04:00
5e729c1e85
reverseproxy: HTTP 504 for upstream timeouts ( #4824 )
...
Closes #4823
2022-06-03 14:13:47 -06:00
f6900fcf53
reverseproxy: Support performing pre-check requests ( #4739 )
2022-05-06 10:50:26 -04:00
3e3bb00265
reverseproxy: Add _ms
placeholders for proxy durations ( #4666 )
...
* reverseproxy: Add `_ms` placeholders for proxy durations
* Add http.request.duration_ms
Also add comments, and change duration_sec to duration_ms
* Add response.duration_ms for consistency
* Add missing godoc comment
Co-authored-by: Matthew Holt <mholt@users.noreply.github.com >
2022-04-11 13:04:05 -06:00