ray
(ray)
December 27, 2023, 12:53pm
1
1. The problem I’m having:
I know there is abort directive. But I don’t know if it’s possible to use it when the status code from reverse_proxy is a certain value, such as 444 (the magic one of nginx). Thanks in advance!
2. Error messages and/or full log output:
N/A
3. Caddy version:
2.7.4
4. How I installed and ran Caddy:
N/A
5. Links to relevant resources:
opened 04:40PM - 16 Nov 20 UTC
closed 07:54PM - 28 Jan 21 UTC
help wanted
feature
Nginx supports `return 444` to just close the connection without responding. Thi… s is often used in a default server so that Nginx doesn't answer any request with an invalid `Host` header. It would be nice to have something similar in Caddy (Doesn't have to use a magic status code of course).
P.S. In the Go `net/http` package, you `panic(http.ErrAbortHandler)` to abort with no response AFAIK (Needs to be checked). But anything calling `recover` along the way also needs to be aware of that.
Mohammed90
(Mohammed Al Sahaf)
December 27, 2023, 3:38pm
2
Of course it’s possible. You need to look into the concept of Intercepting responses . Here’s a quick snippet of how it could work:
reverse_proxy localhost:8080 {
@444 status 444
handle_response @444 {
abort
}
}
More details here:
1 Like
ray
(ray)
December 27, 2023, 5:49pm
3
@Mohammed90 It works! You are so, so, so helpful!!!
2 Likes
system
(system)
Closed
January 26, 2024, 5:50pm
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.