Skip to content

Conversation

@digitalkaoz
Copy link

@digitalkaoz digitalkaoz commented Dec 17, 2025

"No AI was used."

While migrating a high traffic website to caddy we noticed occasional errors we could not reproduce (yet).

The error is expanding glob / syntax error in pattern, we suspect it might be malicious request, but we dont really know.
This PR tries to bring some light by also logging the faulty pattern (where the fs.Glob can throw this error)

versions

  • frankenphp : 1.9.1
  • caddy: 2.10.2

caddy config

{
	metrics # used for datadog

	log default {
		output stdout
		format json
	}

	# see https://frankenphp.dev/docs/config/#caddyfile-config
	# see https://frankenphp.dev/docs/performance/#number-of-threads-and-workers
	frankenphp {
	    num_threads 45  # memory / 50MB per Request - a little headroom
		max_threads 270 # 6 times num_threads
		max_wait_time 20s
	}

	servers {
		trusted_proxies cloudfront {
			# add all cloudfront ips as trusted proxies, so caddy forwards the X-Forwarded headers
			interval 1h
		}
	}
}

#ssl is already terminated (LB) at this point
http:// {
	log

	# modify headers
	@assets path *.js *.css *.ico
	header @assets Cache-Control "s-maxage=31536000, must-revalidate, proxy-revalidate"
	header /* -Server -Expires

	# Enable compression (optional)
	encode zstd br gzip

	# Execute PHP files in the current directory and serve assets
	php_server {
		resolve_root_symlink false
		try_files {path} /index.php
		root /path/to/web
	}

	# error pages
	handle_errors 5xx {
		rewrite * /path/to/static_errors/50x.html
		file_server
	}
}

error log (only ocassionally)

{
  error: "syntax error in pattern",
  level: "error",
  logger: "http.matchers.file"
}

after revisting the config, it might be the error pages ?
frankphp implicitly (afaik) create a fileserver as well for serving assets

@CLAassistant
Copy link

CLAassistant commented Dec 17, 2025

CLA assistant check
All committers have signed the CLA.

@francislavoie
Copy link
Member

francislavoie commented Dec 17, 2025

caddy config (partial, i think its the relevant part)

No, that config doesn't use the file matcher at all (that's just a path matcher). I don't know what your reproduce case is here.

@francislavoie francislavoie added the needs info 📭 Requires more information label Dec 17, 2025
@digitalkaoz
Copy link
Author

digitalkaoz commented Dec 17, 2025

caddy config (partial, i think its the relevant part)

No, that config doesn't use the file matcher at all (that's just a path matcher). I don't know what your reproduce case is here.

Will provide the full config and Caddy Version tomorrow!

@digitalkaoz
Copy link
Author

@francislavoie updated the PR to give more details

@francislavoie
Copy link
Member

If you could make a build with this change and see what information you get out, then that would help to understand what actually happens, and whether there's an actual bug that needs fixing somewhere else. You can use xcaddy to make the build and replace the Caddy package with your branch. Check the xcaddy readme for instructions on that.

@digitalkaoz
Copy link
Author

@francislavoie thats a lot of heavy lifting just for adding a string to an already existing error message. Its only happening here and there within million of requests. Baking a custom image for that would be a lot of effort, this one would be easier to see which patterns are actually causing fs.Glob to error out ;)

@francislavoie
Copy link
Member

Well, this is the first I ever hear of this problem. I don't want to merge something blindly without understanding the underlying cause of the problem.

@digitalkaoz
Copy link
Author

well, this PR is exactly to find out whats wrong, its just an improved error log :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs info 📭 Requires more information

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants