Skip to content

Commit b2f4f15

Browse files
authored
Merge pull request #25 from secondlife/signal/5xx
Add LOG_ONLY_5XX option
2 parents 0f58c81 + 3af58f8 commit b2f4f15

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ENV LISTEN_PORT=80
1414
ENV HEALTHCHECK_PATH="/lb-status/"
1515
ENV STATIC_LOCATIONS=
1616
ENV NO_ACCESS_LOGS=0
17+
ENV LOG_ONLY_5XX=0
1718
EXPOSE 80
1819
STOPSIGNAL SIGQUIT
1920
ENTRYPOINT ["/docker-entrypoint.sh"]

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Pair nginx-proxy with your favorite upstream server (wsgi, uwsgi, asgi, et al.)
2626
| `KEEPALIVE_TIMEOUT` | What value to set HTTP keepalive (This should be higher than your ELB's timeout) | Yes | 65 | |
2727
| `HEALTHCHECK_PATH` | nginx-proxy disables healthcheck path access logs, you can configure the path here | Yes | /lb-status/ | |
2828
| `NO_ACCESS_LOGS` | disable access logs completely | No | 0 | 1 |
29+
| `LOG_ONLY_5XX` | only log 5XX HTTP status access events | No | 0 | 1 |
2930

3031
### Hosting Static Assets
3132

src/etc/nginx/nginx.conf.template

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,18 @@ http {
4747

4848
include /etc/nginx/includes/log-format.conf;
4949

50+
# "5XX" filter for logging
51+
map $status $is5xx {
52+
~^[5] 1;
53+
default 0;
54+
}
55+
56+
{{ if (eq .Env.LOG_ONLY_5XX "1") }}
57+
access_log /dev/stdout json_analytics if=$is5xx;
58+
{{ else }}
5059
# For docker logs to work, we need to output to stdout/stderr
5160
access_log /dev/stdout json_analytics;
61+
{{ end }}
5262

5363
include /etc/nginx/conf.d/*.conf;
5464
}

0 commit comments

Comments
 (0)