1154 Commits

Author SHA1 Message Date
e4447c4ba7 core: Use KeepAliveConfig to pass keepalive_interval to listener's accepted sockets (#7151)
Fix #7144
2025-08-02 09:43:34 -06:00
ab3b2d64ba refactor: use slices.Equal to simplify code (#7141)
Signed-off-by: minxinyi <minxinyi6@outlook.com>
2025-07-23 14:07:46 +00:00
790f3e0885 fileserver: denote license for embedded JavaScript for LibreJS (#7127)
This commit adds support for LibreJS (https://en.wikipedia.org/wiki/GNU_LibreJS).

LibreJS would block this embedded JavaScript because its license is not stated in a machine-readable format.

Signed-off-by: Cédric Félizard <cedric@felizard.fr>
2025-07-16 11:49:49 -06:00
bbf1dfcea2 headers: Support placeholders in replacement search patterns (#7117)
* fix: resolve http.request placeholders in header directive find operation

- Skip regex compilation during provision when placeholders are detected
- Compile regex at runtime after placeholder replacement
- Preserves performance for static regexes while enabling dynamic placeholders
- Fixes #7109

* test: add tests for placeholder detection in header replacements

- Test containsPlaceholders function edge cases
- Test provision skips compilation for dynamic regexes
- Test end-to-end placeholder replacement functionality
2025-07-14 14:55:00 -06:00
aff88d4b26 chore: fix function in comment (#7121)
Signed-off-by: bytesingsong <bytesing@icloud.com>
2025-07-12 11:54:57 +00:00
1209b5c566 reverseproxy: validate versions in http transport (#7112) 2025-07-09 14:13:27 -06:00
c712cfcd76 docs: fix some minor issues in the comments (#7101) 2025-06-30 06:50:00 +00:00
33c88bd2bb refactor: replace HasPrefix+TrimPrefix with CutPrefix (#7095)
Signed-off-by: gopherorg <gopherworld@icloud.com>
2025-06-27 22:04:09 +03:00
3b4d966fba fileserver: Add sort buttons in grid mode (#7089)
* [ADD] sort buttons in grid mode

* [CHANGE] replace spaces with tabs
2025-06-23 13:26:45 -06:00
070d454c0d Use the built-in max/min to simplify the code (#7081)
Signed-off-by: xiaoxiangirl <caojiaqiao@outlook.com>
2025-06-19 16:39:48 -06:00
e039a5bb5c chore: upgrade .golangci.yml and workflow to v2 (#6924)
* chore: upgrade .golangci.yml and workflow to v2

run `golangci-lint fmt`

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

* run `golangci-lint run --fix`

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

* more lint fixes

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

* bring back comments to .golangci.yml

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

* appease the linter some more

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

* oops

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

* use embedded structs

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

* use embedded structs where they were used before

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

* disable rule  `-QF1006`

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

* missed a spot

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

---------

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
2025-06-03 02:24:32 +03:00
5b2eb66418 Use slices.Contains to simplify code (#7039)
Signed-off-by: tongjicoder <tongjicoder@icloud.com>
2025-05-31 12:03:06 -06:00
94147caf31 fileserver: map invalid path errors to fs.ErrInvalid, and return 400 for any invalid path errors. (close #7008) (#7017) 2025-05-13 07:43:27 -06:00
716d72e475 intercept: implement Unwrap for interceptedResponseHandler (#7016) 2025-05-12 12:15:34 -06:00
aa3d20be3e reverseproxy: Use DialTLSContext if ServerName has placeholder (#6955)
Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
2025-04-28 09:14:09 -06:00
54d03ced48 fileserver: Add support for .avif image format (#6988) 2025-04-28 08:32:59 -06:00
737936c06b reverseproxy: reference correct field name in LoadModule (#6978)
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
2025-04-21 08:43:27 -06:00
1bfa111552 caddytls: Prefer managed wildcard certs over individual subdomain certs (#6959)
* caddytls: Prefer managed wildcard certs over individual subdomain certs

* Repurpose force_automate as no_wildcard

* Fix a couple bugs

* Restore force_automate and use automate loader as wildcard override
2025-04-18 11:44:23 -06:00
5be77d07ab caddyauth: Set authentication provider error in placeholder (#6932)
* caddyauth: Set authentication provider error in placeholder for handle_errors directive

* caddyauth: Simplify error placeholder setting for authentication provider
2025-04-15 22:32:08 +00:00
6c38ae7381 reverseproxy: Add valid Upstream to DialInfo in active health checks (#6949)
Currently if we extract the DialInfo from a Request Context during an active health check, then the Upstream in the DialInfo is nil.

This PR attempts to set the Upstream to a sensible value, based on wether or not the Upstream has been overriden in the active health check's config.
2025-04-15 08:44:53 -06:00
b06a9496d1 caddyhttp: Document side effect of HTTP/3 early data (close #6936) 2025-04-08 13:59:02 -06:00
5a6b2f8d1d events: Refactor; move Event into core, so core can emit events (#6930)
* events: Refactor; move Event into core, so core can emit events

Requires some slight trickery to invert dependencies. We can't have the caddy package import the caddyevents package, because caddyevents imports caddy. Interface to the rescue!

Also add two new events, experimentally: started, and stopping. At the request of a sponsor.

Also rename "Filesystems" to "FileSystems" to match Go convention (unrelated to events, was just bugging me when I noticed it).

* Coupla bug fixes

* lol whoops
2025-03-29 08:15:43 -06:00
173573035c core: add modular network_proxy support (#6399)
* core: add modular `network_proxy` support

Co-authored-by: @ImpostorKeanu
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

* move modules around

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

* add caddyfile implementation

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

* address feedbcak

* Apply suggestions from code review

Co-authored-by: Francis Lavoie <lavofr@gmail.com>

* adapt ForwardProxyURL to use the NetworkProxyRaw

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

* remove redundant `url`  in log

Co-authored-by: Matt Holt <mholt@users.noreply.github.com>

* code review

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

* remove `.source` from the module ID

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

---------

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
Co-authored-by: Francis Lavoie <lavofr@gmail.com>
Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
2025-03-21 17:06:15 +00:00
1f8dab572c caddytls: Don't publish ECH configs if other records don't exist
Publishing a DNS record for a name that doesn't have any could make wildcards ineffective, which would be surprising for site owners and could lead to downtime.
2025-03-12 16:33:14 -06:00
2ac09fdb20 requestbody: Fix ContentLength calculation after body replacement (#6896) 2025-03-12 22:18:02 +00:00
dccf3d8982 requestbody: Add set option to replace request body (#5795)
Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
2025-03-12 19:38:51 +00:00
af2d33afbb headers: Allow nil HeaderOps (fix #6893) 2025-03-11 08:52:15 -06:00
f4432a306a caddyfile: add error handling for unrecognized subdirective/options in various modules (#6884) 2025-03-08 23:45:05 +03:00
220cd1c2bc reverseproxy: more comments about buffering and add new tests (#6778)
Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
2025-03-07 11:22:43 -07:00
1975408d89 chore: Remove unnecessary explicit type parameters 2025-03-07 11:18:00 -07:00
d7764dfdbb caddytls: Encrypted ClientHello (ECH) (#6862)
* caddytls: Initial commit of Encrypted ClientHello (ECH)

* WIP Caddyfile

* Fill out Caddyfile support

* Enhance godoc comments

* Augment, don't overwrite, HTTPS records

* WIP

* WIP: publication history

* Fix republication logic

* Apply global DNS module to ACME challenges

This allows DNS challenges to be enabled without locally-configured DNS modules

* Ignore false positive from prealloc linter

* ci: Use only latest Go version (1.24 currently)

We no longer support older Go versions, for security benefits.

* Remove old commented code

Static ECH keys for now

* Implement SendAsRetry
2025-03-05 17:04:10 -07:00
22563a70eb file_server: use the UTC timezone for modified time (#6830)
* use UTC timezone for modified time

* use http.ParseTime to handle If-Modified-Since

* use time.Compare to simplify comparison

* take the directory's modtime into consideration when calculating lastModified

* update comments about If-Modified-Since's handling
2025-02-10 08:39:43 -07:00
9b74a53e51 Revert "logging: Always set fields func; fix #6829"
This reverts commit 932dac157a3c4693b80576477498bb86208b9b30.

Somehow the code I was looking at changed when I committed, without realizing it. This has already been fixed in #6777.
2025-02-07 06:23:43 -07:00
932dac157a logging: Always set fields func; fix #6829 2025-02-07 06:18:37 -07:00
9283770f68 reverseproxy: ignore duplicate collector registration error (#6820)
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
2025-02-04 10:55:30 +03:00
904a0fa368 reverse_proxy: re-add healthy upstreams metric (#6806)
* reverse_proxy: re-add healthy upstreams metric

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

* lint

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

---------

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
2025-01-27 14:30:54 -07:00
1115158616 caddyhttp: ResponseRecorder sets stream regardless of 1xx
Fixes a panic where rr.stream is not true when it should be in the event of 1xx, because the buf is nil
2025-01-27 08:18:37 -07:00
e7da3b267b reverseproxy: Via header (#6275) 2025-01-17 06:49:01 -07:00
9e0e5a4b4c logging: Fix crash if logging error is not HandlerError (#6777)
Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
2025-01-16 10:06:29 -07:00
1f35a8a402 fastcgi: improve parsePHPFastCGI docs (#6779) 2025-01-09 11:54:44 -07:00
e48b75843b header: match subdirective for response matching (#6765) 2025-01-07 22:48:06 -07:00
50778b5542 fix: disable h3 for unix domain socket (#6769) 2025-01-07 17:21:57 -07:00
1bd567d7ad reverseproxy: buffer requests for fastcgi by default (#6759)
* buffer requests for fastcgi by default

* fix import cycle

* fix the return value of bufferedBody

* more comments about fastcgi buffering

---------

Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
2025-01-02 11:18:25 -07:00
5ba1e06fd6 encode: try to use sendfile when compression is not used (#6749)
* try to use sendfile when encode is enabled

* change variable name

* add comments

* remove connect check since it's done in Write method
2024-12-20 21:37:16 +00:00
c216cf551d caddyhttp: Allow matching Transfer-Encoding, add to access logs (#6629)
* caddyhttp: Allow matching Transfer-Encoding

* Log transfer_encoding on the request

---------

Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
2024-12-20 11:16:34 -07:00
6790c0e38a fastcgi: check for CONTENT_LENGTH when sending requests (#6661)
* fastcgi: check for CONTENT_LENGTH when sending requests

* order imports

* use strconv.ParseUint instead of strconv.ParseInt

Co-authored-by: Kévin Dunglas <kevin@dunglas.fr>

---------

Co-authored-by: Kévin Dunglas <kevin@dunglas.fr>
2024-12-18 00:22:12 +00:00
c864b82ae1 reverseproxy: Set Content-Length when body is fully buffered (#6638) 2024-12-17 23:36:13 +00:00
328fb614f0 reverseproxy: Only handle websocket protocol (#6740) 2024-12-11 11:17:05 -07:00
bcaa8aaf11 encode: write status immediate for success response for CONNECT requests (#6738)
* encode: write status immediate for success response for CONNECT requests

* fix compile

* fix test

* fix lint

* treat first write and flush for encode response writer to CONNECT request as success if status is not set explicitly
2024-12-11 11:15:01 -07:00
d0e209e1da encode: good defaults (#6737)
* feat: good default for encode

* fix tests and add a new one
2024-12-10 16:48:30 -07:00