|
39 | 39 | default: '1k' |
40 | 40 | ) |
41 | 41 |
|
| 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 | + |
42 | 78 | only_if do |
43 | 79 | command('nginx').exist? |
44 | 80 | end |
|
140 | 176 | its('client_header_buffer_size') { should eq CLIENT_HEADER_BUFFER_SIZE } |
141 | 177 | end |
142 | 178 | 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 } |
144 | 180 | end |
145 | 181 | end |
146 | 182 |
|
|
149 | 185 | title 'Control timeouts to improve performance' |
150 | 186 | desc 'Control timeouts to improve server performance and cut clients.' |
151 | 187 | describe parse_config_file(nginx_conf, options) do |
152 | | - its('keepalive_timeout') { should eq '5 5' } |
| 188 | + its('keepalive_timeout') { should eq KEEPALIVE_TIMEOUT } |
153 | 189 | end |
154 | 190 | 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 } |
156 | 192 | end |
157 | 193 | 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 } |
159 | 195 | end |
160 | 196 | describe parse_config_file(nginx_hardening, options) do |
161 | | - its('send_timeout') { should eq '10' } |
| 197 | + its('send_timeout') { should eq SEND_TIMEOUT } |
162 | 198 | end |
163 | 199 | end |
164 | 200 |
|
|
0 commit comments