Skip to content

Commit c5b7d08

Browse files
author
Bennett Goble
committed
Allow keepalive value to be adjusted
Some apps have a keepalive value longer than ELB's default 60s. For example, AIS has a timeout value of 120 (gross) so we need to allow the proxy's to be adjusted.
1 parent fb59fbb commit c5b7d08

File tree

6 files changed

+8
-1
lines changed

6 files changed

+8
-1
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ RUN apk add --no-cache \
2525
nginx \
2626
nginx-mod-http-headers-more
2727
COPY src /
28+
ENV KEEPALIVE_TIMEOUT=65
2829
ENV PROXY_UWSGI=0
2930
ENV LISTEN_PORT=80
3031
ENV STATIC_LOCATIONS=

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Pair nginx-proxy with your favorite upstream server (wsgi, uwsgi, asgi, et al.)
1414
| `SILENT` | Silence entrypoint output | No | | |
1515
| `STATIC_LOCATIONS` | Static asset mappings | No | | |
1616
| `PROXY_UWSGI` | Whether to use native uwsgi support | No | 0 | 1 |
17+
| `KEEPALIVE_TIMEOUT` | What value to set HTTP keepalive (This should be higher than your ELB's timeout) | Yes | 65 | |
1718

1819
### Hosting Static Assets
1920

src/docker-entrypoint.d/00-render-templates.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ set -eo pipefail
44

55
source /docker-entrypoint.d/functions
66

7+
# Render main nginx.conf
8+
cat "/etc/nginx/nginx.conf.template" | gomplate > "/etc/nginx/nginx.conf"
9+
710
for f in /etc/nginx/templates/*.template
811
do
912
final=$(basename "$f")

src/etc/nginx/nginx.conf renamed to src/etc/nginx/nginx.conf.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ http {
2424
#sendfile on;
2525
#tcp_nopush on;
2626

27-
keepalive_timeout 65;
27+
keepalive_timeout {{ .Env.KEEPALIVE_TIMEOUT }};
2828
#gzip on;
2929

3030
# Don't leak information about this server.

test/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function fail {
88
}
99

1010
LISTEN_PORT="8080" \
11+
KEEPALIVE_TIMEOUT="65" \
1112
PROXY_REVERSE_URL="http://localhost:8081" \
1213
SERVER_NAME="localhost" \
1314
STATIC_LOCATIONS="/static/:/test/static/" \

test_uwsgi/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function fail {
88
}
99

1010
LISTEN_PORT="8080" \
11+
KEEPALIVE_TIMEOUT="65" \
1112
PROXY_REVERSE_URL="localhost:8081" \
1213
SERVER_NAME="localhost" \
1314
PROXY_UWSGI="1" \

0 commit comments

Comments
 (0)