Skip to content

Commit ca36161

Browse files
authored
Merge pull request #10 from Intellection/update-configs
Configure timeouts & some improvements
2 parents b87f59b + ac09a63 commit ca36161

File tree

5 files changed

+69
-20
lines changed

5 files changed

+69
-20
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# Changelog
22

3+
## 1.19.5-7
4+
5+
* Set `daemon` to `off`.
6+
* Set `multi_accept` to `on`.
7+
* Set `use` to `epoll`.
8+
* Set `aio` to `threads`.
9+
* Set `aio_write` to `on`.
10+
* Set `tcp_nodelay` to `on`.
11+
* Set `reset_timedout_connection` to `on`.
12+
* Set `port_in_redirect` to `off`.
13+
* Add `http_upgrade` and `proxy_connection` to log format.
14+
* Remove setting of `sendfile` (turns it off).
15+
* Remove setting of `client_max_body_size` (defaults to `1m`).
16+
* Remove setting of `client_body_buffer_size` (defaults to `16k`).
17+
* Reduce `client_body_timeout` to `60s` (same as default).
18+
* Reduce `client_header_timeout` to `60s` (same as default).
19+
* Reduce `keepalive_timeout` to `75s` (same as default).
20+
* Reduce `proxy_connect_timeout` to `5s`.
21+
* Reduce `proxy_read_timeout` to `60s` (same as default).
22+
* Reduce `worker_shutdown_timeout` to `240s`.
23+
* Set `Proxy` header to `""` to mitigate httpoxy vulnerability.
24+
* Disable keep-alive on healthcheck server.
25+
* Enable support for websockets.
26+
327
## 1.19.5-6
428

529
* Set `client_body_buffer_size` to `128k`.

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,5 @@ COPY ./config/ /etc/nginx/
5858
STOPSIGNAL SIGQUIT
5959
EXPOSE 8080
6060
USER nginx:nginx
61+
62+
CMD ["nginx"]

config/http.conf

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,24 @@ http {
22
include /etc/nginx/mime.types;
33
include /etc/nginx/log.conf;
44

5-
server_tokens off;
6-
sendfile on;
7-
tcp_nopush on;
5+
aio threads;
6+
aio_write on;
7+
8+
tcp_nopush on;
9+
tcp_nodelay on;
810

9-
client_max_body_size 500m;
10-
client_body_buffer_size 128k;
11-
client_body_timeout 300s;
12-
client_header_timeout 605s;
13-
keepalive_timeout 605s;
14-
proxy_connect_timeout 60s;
15-
proxy_read_timeout 600s;
16-
proxy_send_timeout 60s;
17-
send_timeout 60s;
11+
client_body_timeout 60s;
12+
client_header_timeout 60s;
13+
keepalive_timeout 75s;
14+
proxy_connect_timeout 5s;
15+
proxy_read_timeout 60s;
16+
proxy_send_timeout 60s;
17+
send_timeout 60s;
18+
19+
reset_timedout_connection on;
20+
21+
port_in_redirect off;
22+
server_tokens off;
1823

1924
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
2025
# scheme used to connect to this server
@@ -44,9 +49,19 @@ http {
4449
'' $request_id;
4550
}
4651

52+
# See https://www.nginx.com/blog/websocket-nginx
53+
map $http_upgrade $proxy_connection {
54+
default Upgrade;
55+
'' '';
56+
}
57+
4758
proxy_http_version 1.1;
48-
proxy_set_header Connection "";
4959
proxy_set_header Host $host;
60+
proxy_set_header Connection $proxy_connection;
61+
proxy_set_header Upgrade $http_upgrade;
62+
63+
# Mitigate httpoxy vulnerability
64+
proxy_set_header Proxy "";
5065

5166
proxy_set_header X-Real-IP $remote_addr;
5267
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -59,11 +74,13 @@ http {
5974
include /etc/nginx/app.conf;
6075

6176
server {
62-
listen 18081 default_server;
77+
listen 18081 default_server;
78+
79+
access_log off;
80+
keepalive_timeout 0;
6381

64-
location /healthz {
65-
access_log off;
66-
return 200;
67-
}
82+
location /healthz {
83+
return 200;
84+
}
6885
}
6986
}

config/log.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ log_format main_json escape=json
99
'"host":"$host",'
1010
'"http_connection":"$http_connection",'
1111
'"http_referer":"$http_referer",'
12+
'"http_upgrade":"$http_upgrade",'
1213
'"http_user_agent":"$http_user_agent",'
1314
'"http_x_amzn_trace_id":"$http_x_amzn_trace_id",'
1415
'"http_x_forwarded_for":"$http_x_forwarded_for",'
16+
'"proxy_connection":"$proxy_connection",'
1517
'"proxy_x_forwarded_port":"$proxy_x_forwarded_port",'
1618
'"proxy_x_forwarded_proto":"$proxy_x_forwarded_proto",'
1719
'"proxy_x_forwarded_ssl":"$proxy_x_forwarded_ssl",'

config/main.conf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
daemon off;
2+
13
worker_processes auto;
24
worker_rlimit_nofile 8192;
3-
worker_shutdown_timeout 630s;
5+
worker_shutdown_timeout 240s;
46

57
events {
6-
worker_connections 8000;
8+
multi_accept on;
9+
worker_connections 8000;
10+
use epoll;
711
}

0 commit comments

Comments
 (0)