dnsdist: Send better HTTP status codes, handle ACL drops earlier#7917
dnsdist: Send better HTTP status codes, handle ACL drops earlier#7917rgacogne merged 2 commits intoPowerDNS:masterfrom
Conversation
|
here is our line of reasoning why we consider it discouraged to close a TCP connection directly instead of providing a proper HTTP response code: If the TCP connection comes from a client that is not allowed as per ACL why not answer with And if dnsdist on a plain (non-DoH) frontend were to answer with
this sound more like an issue with the backend? and |
|
Right, I understand that closing the TCP connection right away will not play well with some HTTP clients or proxies. I will make sure we send a 403 code instead when the source IP is not allowed by the ACL.
This PR currently turns that into a 502 instead. I don't really know if 502 or 504 is more appropriate, since it's not really a timeout at that point. I'm not sure it matters much for this case, since it's very unlikely to happen. Thanks a lot for the feedback, this is very useful! |
Done! |
Thanks a lot for considering our concerns, this is very encouraging when feedback is actually taken into account!
we would suggest to aim for the following principles in this area of "what response code to return?". We understand that this is not trivial since not every possible error condition has a perfectly matching and specified HTTP error code representation. a) try to match the HTTP error code description as specified in RFC as good as possible Some more explaining about (d) ref: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream |
3420f82 to
3b6a689
Compare
omoerbeek
left a comment
There was a problem hiding this comment.
A little late... Somehow I missed this review request. Sorry!
Short description
We used to send a 500 status code when a query was dropped, regardless of the reason. This PR tries to return a more appropriate status code instead.
It also moves the ACL check right after the connection has been accepted, before the HTTP/2 and DNS parsing, to avoid wasting cycles on queries that we will end up dropping anyway. It's a bit more mean to HTTP clients that will get their TCP connection closed right away instead of a 403 status code, but I think it's worth it. Comments welcome :)
Checklist
I have: