Is there a technical requirement (e.g., RFC) to serve a 404 response?
Or does some other problem emerge if requests not found are dropped or replies empty?
Is there a technical requirement (e.g., RFC) to serve a 404 response?
Or does some other problem emerge if requests not found are dropped or replies empty?
An HTTP server is required to reply with an HTTP response message. Every HTTP request returns a status code, see RFC 1945.
The 4xx/5xx codes are just the error codes that are usually displayed to the user.
RFC 7230 Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing (Standards Track)
Section 2.1
...
A server responds to a client's request by sending one or more HTTP response messages, each beginning with a status line that includes the protocol version, a success or error code, and textual reason phrase ...
According to this RFC, you can't simply drop the connection or send an empty reply.
400 for an invalid Host: header (Section 5.4 of the RFC 7239). You can rate limit requests and respond with 429. If a client host is really hostile and generates too many 4xx errors then you can block them at IP level (fail2ban etc.) and drop connection (RFC 6585 Section 7.2)
– AlexD
Jan 07 '22 at 13:28