Skip to content

Commit e9e59e6

Browse files
committed
Add support for STATUS_LISTEN_PORT env var so that we can re-map the status page port used by datadog/metric collectors
1 parent 486f70d commit e9e59e6

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ COPY src /
1111
ENV KEEPALIVE_TIMEOUT=65
1212
ENV PROXY_UWSGI=0
1313
ENV LISTEN_PORT=80
14+
ENV STATUS_LISTEN_PORT=8091
1415
ENV HEALTHCHECK_PATH="/lb-status/"
1516
ENV STATIC_LOCATIONS=
1617
ENV NO_ACCESS_LOGS=0
@@ -41,4 +42,4 @@ RUN /test_uwsgi/test.sh
4142
FROM base
4243
LABEL "com.datadoghq.ad.check_names"='["nginx"]'
4344
LABEL "com.datadoghq.ad.init_configs"='[{}]'
44-
LABEL "com.datadoghq.ad.instances"='[{"nginx_status_url": "http://localhost:8091/nginx_status/"}]'
45+
LABEL "com.datadoghq.ad.instances"='[{"nginx_status_url": "http://%%host%%:%%env_STATUS_LISTEN_PORT%%/nginx_status/"}]'

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Pair nginx-proxy with your favorite upstream server (wsgi, uwsgi, asgi, et al.)
1717
| Environment Variable | Description | Required | Default | Example |
1818
|----------------------|-------------|----------|---------|---------|
1919
| `LISTEN_PORT` | Server port | Yes | 80 | |
20+
| `STATUS_LISTEN_PORT` | nginx status port | No | 8091 | |
2021
| `UPSTREAM_SERVER` | Upstream server | Yes | | myapp:8080 fail_timeout=0, unix://mnt/server.sock |
2122
| `PROXY_REVERSE_URL` | Upstream server URL (Deprecated, please use UPSTREAM_SERVER) | No | | http://myapp:8080 |
2223
| `SERVER_NAME` | Allowed server names (hostnames) | Yes | | |
@@ -65,8 +66,11 @@ then set `PROXY_REVERSE_URL=localhost:8000`.)
6566

6667
## Nginx status
6768

68-
The [nginx status][] page is configured to run at
69-
http://localhost:8091/nginx_status. This endpoint can be used by Datadog and
69+
The [nginx status][] page is configured to run at
70+
http://localhost:${STATUS_LISTEN_PORT}/nginx_status.
71+
72+
Set the `STATUS_LISTEN_PORT` environment variable when you start the container
73+
(default: `8091`) to change the port. This endpoint can be used by Datadog and
7074
other metrics collectors.
7175

7276
## Development

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# NGINX status/stats used by datadog, et al.
22
server {
3-
listen 8091;
3+
listen {{ .Env.STATUS_LISTEN_PORT }};
44
server_name _;
55

66
access_log off;

0 commit comments

Comments
 (0)