Skip to content

Commit 6725b98

Browse files
atomic111chris-rock
authored andcommitted
added attributes for large_client_header_buffer, keepalive_timeout, client_body_timeout, client_header_timeout, send_timeout
Signed-off-by: Patrick Münch <patrick.muench1111@gmail.com>
1 parent edd7a32 commit 6725b98

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

controls/nginx_spec.rb

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,42 @@
3939
default: '1k'
4040
)
4141

42+
LARGE_CLIENT_HEADER_BUFFER = attribute(
43+
'large_client_header_buffers',
44+
description: 'Sets the maximum number and size of buffers used for reading large client request header. A request line cannot exceed the size of one buffer, or the 414 (Request-URI Too Large) error is returned to the client. A request header field cannot exceed the size of one buffer as well, or the 400 (Bad Request) error is returned to the client. Buffers are allocated only on demand. By default, the buffer size is equal to 8K bytes. If after the end of request processing a connection is transitioned into the keep-alive state, these buffers are released.',
45+
default: '2 1k'
46+
)
47+
48+
KEEPALIVE_TIMEOUT = attribute(
49+
'keepalive_timeout',
50+
description: 'The first parameter sets a timeout during which a keep-alive client connection will stay open on the server side. The zero value disables keep-alive client connections. The optional second parameter sets a value in the “Keep-Alive: timeout=time” response header field. Two parameters may differ.',
51+
default: '5 5'
52+
)
53+
54+
CLIENT_BODY_TIMEOUT = attribute(
55+
'client_body_timeout',
56+
description: 'Defines a timeout for reading client request body. The timeout is set only for a period between two successive read operations, not for the transmission of the whole request body. If a client does not transmit anything within this time, the 408 (Request Time-out) error is returned to the client.',
57+
default: '10'
58+
)
59+
60+
CLIENT_HEADER_TIMEOUT = attribute(
61+
'client_header_timeout',
62+
description: 'Defines a timeout for reading client request header. If a client does not transmit the entire header within this time, the 408 (Request Time-out) error is returned to the client.',
63+
default: '10'
64+
)
65+
66+
SEND_TIMEOUT = attribute(
67+
'send_timeout',
68+
description: 'Sets a timeout for transmitting a response to the client. The timeout is set only between two successive write operations, not for the transmission of the whole response. If the client does not receive anything within this time, the connection is closed.',
69+
default: '10'
70+
)
71+
72+
HTTP_METHODS = attribute(
73+
'http_methods',
74+
description: 'Specify the used HTTP methods',
75+
default: 'GET\|HEAD\|POST'
76+
)
77+
4278
only_if do
4379
command('nginx').exist?
4480
end
@@ -140,7 +176,7 @@
140176
its('client_header_buffer_size') { should eq CLIENT_HEADER_BUFFER_SIZE }
141177
end
142178
describe parse_config_file(nginx_hardening, options) do
143-
its('large_client_header_buffers') { should eq '2 1k' }
179+
its('large_client_header_buffers') { should eq LARGE_CLIENT_HEADER_BUFFER }
144180
end
145181
end
146182

@@ -149,16 +185,16 @@
149185
title 'Control timeouts to improve performance'
150186
desc 'Control timeouts to improve server performance and cut clients.'
151187
describe parse_config_file(nginx_conf, options) do
152-
its('keepalive_timeout') { should eq '5 5' }
188+
its('keepalive_timeout') { should eq KEEPALIVE_TIMEOUT }
153189
end
154190
describe parse_config_file(nginx_hardening, options) do
155-
its('client_body_timeout') { should eq '10' }
191+
its('client_body_timeout') { should eq CLIENT_BODY_TIMEOUT }
156192
end
157193
describe parse_config_file(nginx_hardening, options) do
158-
its('client_header_timeout') { should eq '10' }
194+
its('client_header_timeout') { should eq CLIENT_HEADER_TIMEOUT }
159195
end
160196
describe parse_config_file(nginx_hardening, options) do
161-
its('send_timeout') { should eq '10' }
197+
its('send_timeout') { should eq SEND_TIMEOUT }
162198
end
163199
end
164200

0 commit comments

Comments
 (0)