Nginx has the directive client_header_buffer_size which controls how big the buffer for the header part of a client request is.
Nginx also has large_client_header_buffers as fallback if the normal buffer is too small. They are allocated and read into. There can be multiple large_client_header_buffers. If these buffers are also too small an error is sent to the client.
Nginx picks the appropriate virtual server depending on the request: LINK.
See also article How nginx processes a request
At first it uses the default server, and with more information maybe another server configuration will be picked. This is done by checking the applicable server at different stages of request parsing:
3.1 during SSL handshake
3.2 after processing the request line
3.3 after processing the Host header field
Status quo
in branch #22 the clientHeaderBufferSize is fixed
choosing the correct server configuration is not implemented yet
Thoughts for our implementation
It would be nice to be able to configure the client_header_buffer_size (1).
However the additional large buffers (2) seem more complex and also don't play nice with the subject: we have to come from poll (or equivalent) before we can read. So we can't just continue to read into the allocated buffers, but have to return after one read.
Subdividing the parsing could lead to a better server configuration choice. Maybe a small change since only one of the three cases seems applicable:
We don't do SSL (so no 3.1).
I'm not sure what additional information would be availabe after processing the request line (3.2). Host and Port is checked at accept() stage
After parsing the Host field (3.3) we could choose a better server
Suggestion
[ ] parse client_header_buffer_size as directive (server scope), also set default value
[ ] allocate buffer depending on the size and read bufferSize for request header
[ ] be able to pause parsing of request header, after Host field was found
What does Nginx do
Nginx has the directive client_header_buffer_size which controls how big the buffer for the header part of a client request is.
Nginx also has large_client_header_buffers as fallback if the normal buffer is too small. They are allocated and read into. There can be multiple large_client_header_buffers. If these buffers are also too small an error is sent to the client.
Nginx picks the appropriate virtual server depending on the request: LINK. See also article How nginx processes a request At first it uses the default server, and with more information maybe another server configuration will be picked. This is done by checking the applicable server at different stages of request parsing: 3.1 during SSL handshake 3.2 after processing the request line 3.3 after processing the Host header field
Status quo
Thoughts for our implementation
Suggestion