caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
58.43k stars 4.04k forks source link

Including matcher in 'handle_response' line has confusing error #6529

Open foxt opened 2 months ago

foxt commented 2 months ago

If you use the following Caddyfile:

reverse_proxy localhost:8000 {
    handle_response header Foo {
        # do something
    }
}

you will get the following error: adapting config using caddyfile: parsing caddyfile tokens for 'reverse_proxy': configuring 'handle_response' for status code replacement is no longer supported. Use 'replace_status' instead. even though you're not touching the status code.

If you use either

handle_response header Foo * {

or

@bad status 500
handle_response @bad {

no error is raised.

Seems to be a check implemented at https://github.com/caddyserver/caddy/blob/54a0c8f94821f393edec1a1bc9459f2363c95117/modules/caddyhttp/reverseproxy/caddyfile.go#L915 that just complains if there are two parameters passed to handle_response.

mholt commented 2 months ago

Ah thanks.

@francislavoie This was from about 2 years ago; maybe it's time to revisit while we're at it? The previous line says // TODO: Remove this check at some point in the future.