I can't figure this out.
I'm trying to create an apache configuration applicable to all domains hosted on the same box so that if a request to any url returns an error-based code to the client (like 4xx or 5xx), a "connection: close" (keep-alive disabled) is also set in the HTTP headers for the client, whereas all the good requests will have keep-alive enabled.
I ask this because I think hackers are trying to tie up connections to my server by deliberately trying to access URLs that return errors (particularly the 404 not found error) and I want to make it so apache literally closes the connection on the errors.
And why the "connection: close" specifically? because cloudflare includes that header when it issues the 403 not authorized page when one accesses a homepage of a different site (because that site wants to perform human verification first).
Any way I can do this with just apache? or would I have to somehow write up an apache module (if its possible) to achieve this task?