From 621793c5dab8fb86025ae06345158b893b47a0aa Mon Sep 17 00:00:00 2001 From: Daisuke Fujita Date: Thu, 28 Sep 2017 15:57:08 +0900 Subject: [PATCH] Add :8090/nginx_status endpoint for monitoring --- README.md | 13 +++++++++++++ docker-compose.yml | 1 + files/nginx.conf.tmpl | 9 +++++++++ 3 files changed, 23 insertions(+) diff --git a/README.md b/README.md index 6fec550..add1a01 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ $ docker run \ --rm \ --name nginx-basic-auth-proxy \ -p 8080:80 \ + -p 8090:8090 \ -e BASIC_AUTH_USERNAME=username \ -e BASIC_AUTH_PASSWORD=password \ -e PROXY_PASS=https://www.google.com \ @@ -37,6 +38,18 @@ $ docker-compose up # - Password: password ``` +### Endpoint for monitoring + +`:8090/nginx_status` returns the metrics of Nginx. + +```sh-session +$ curl localhost:8090/nginx_status +Active connections: 1 +server accepts handled requests + 8 8 8 +Reading: 0 Writing: 1 Waiting: 0 +``` + ## Environment variables ### Required diff --git a/docker-compose.yml b/docker-compose.yml index dca12fa..8671198 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,7 @@ services: image: quay.io/dtan4/nginx-basic-auth-proxy:latest ports: - 8080:80 + - 8090:8090 environment: - BASIC_AUTH_USERNAME=username - BASIC_AUTH_PASSWORD=password diff --git a/files/nginx.conf.tmpl b/files/nginx.conf.tmpl index 1a70d01..4a22ecd 100644 --- a/files/nginx.conf.tmpl +++ b/files/nginx.conf.tmpl @@ -30,4 +30,13 @@ http { proxy_set_header Authorization ""; } } + + server { + listen 8090; + + location /nginx_status { + stub_status on; + access_log off; + } + } }