Skip to content

intercept causing requests to be handled twice #6992

Open
@mohammed90

Description

@mohammed90

Update: see this comment for the effect of this bug.

As the subject says, using the intercept handler with reverse_proxy causes duplication of headers received from upstream.

Using this Caddyfile:

localhost {
	log
	intercept {
		handle_response {
			header {
				Header-Three Value-3
			}
		}
	}
	reverse_proxy localhost:8080
}

http://localhost:8080/ {
	header {
		Header-One Value-1
		Header-Two Value-2
	}
	respond "Hello, World!"
}

Note the headers received by the client:

$ curl -v https://localhost/
* Request completely sent off
< HTTP/2 200
< alt-svc: h3=":443"; ma=2592000
< content-type: text/plain; charset=utf-8
< content-type: text/plain; charset=utf-8
< date: Mon, 28 Apr 2025 21:15:40 GMT
< date: Mon, 28 Apr 2025 21:15:40 GMT
< header-one: Value-1
< header-one: Value-1
< header-three: Value-3
< header-two: Value-2
< header-two: Value-2
< server: Caddy
< via: 1.1 Caddy
< via: 1.1 Caddy
< content-length: 13
<
* Connection #0 to host localhost left intact
Hello, World!%

The workaround for reverse_proxy is using handle_response.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions