Returning custom error pages with 410 Gone

1. Caddy version (caddy version):

v2.0.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=

2. How I run Caddy:

systemctl enable --now caddy

a. System environment:

CentOS 8, which uses systemd.

b. Command:

systemctl enable --now caddy

3. The problem I’m having:

I have a couple of URLs that I want to respond to with HTTP 410 Gone and a custom error page. One of them is /GM/. My custom 404 page at /404/ works fine, but 410 isn’t.

4. Error messages and/or full log output:

No errors.

5. What I already tried:

	handle_errors {
		rewrite * /{http.error.status_code}/
		file_server
	}
# in conjunction with
	respond /GM/ 410
# or maybe
	handle /GM/ {
		respond 410
	}


looks like it should work, but with respond /GM/ 410 all I’m getting is a blank page with an HTTP 410 response.

6. Links to relevant resources:

I don’t see why this would work because handle_errors is already using rewrite: Caddy 2 handle_error examples with custom error pages? - #8 by francislavoie

handle_errors only gets invoked as a result of an error from one of the handlers, not from explicit responses with non-2xx statuses.

I’m still not entirely sure how to handle those kinds of situations where you want to explicitly trigger an error based on some matcher. @matt got any ideas?

This topic was automatically closed after 30 days. New replies are no longer allowed.