Unverified Commit 7f595108 authored by Sergei Krot's avatar Sergei Krot Committed by GitHub
Browse files

PROD-1889 enabling nginx status (#16)

* PROD-1889 adding nginx status so this could be consumed by DataDog

* PROD-1889 bumping version

* PROD-1889 adding env variables to customize the status page

* PROD-1889 updating CHANGELOG

* PROD-1889 updating docs

* PROD-1889 more doc updates
parent 4cf3a637
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
# `nginx-sidecar` changelog

## 0.3.7

- Enabling ngnix status for detailed monitoring.
- New variables are:
 - `NGINX_STATUS_PORT` (default `81`) a port to run the status module on
 - `NGINX_STATUS_ALLOW_FROM` (default `all`) IP, CIDR, `all` for the nginx config's `allow` statement (http://nginx.org/en/docs/http/ngx_http_access_module.html)

## 0.3.6

- Allow specifying the app hostname to proxy to.
+18 −0
Original line number Diff line number Diff line
@@ -8,6 +8,12 @@ A simple nginx reverse proxy side-car, which can be placed in front an applicati
 - The `NGINX_PORT` environment variable should be set to the port nginx should bind to.
 - The `APP_PORT` environment variable should be set to the port that the application is bound to inside the `app` container.

## Stats Monitoring

We've enabled `http_stub_status_module` access to help with monitoring integration. By default it is listening on port _81_ with `allow all` as restriction. You can customize this with:
- `NGINX_STATUS_PORT` (default `81`) a port to run the status module on
- `NGINX_STATUS_ALLOW_FROM` (default `all`) IP, CIDR, `all` for the nginx config's `allow` statement (http://nginx.org/en/docs/http/ngx_http_access_module.html)

## Example

In your `.hopper/config.yml`:
@@ -54,6 +60,18 @@ services:
          value: 'app'
        - name: APP_PORT
          value: '3001'
        # If you want to customize monitoring status endpoint
        - name: NGINX_PORT
          value: '18081'
        - name: NGINX_STATUS_ALLOW_FROM
          value: '172.0.0.0/8'
        
        # If your datadog agent has Autodiscovery enabled, you can provide additional docker labels
        # in order to expose them
        dockerLabels:
          com.datadoghq.ad.check_names: '["nginx"]'
          com.datadoghq.ad.init_configs: '[{}]'
          com.datadoghq.ad.instances: '[{"nginx_status_url": "http://%%host%%:81/nginx_status/"}]'

  # ...
```
+1 −1
Original line number Diff line number Diff line
0.3.6
0.3.7
+15 −0
Original line number Diff line number Diff line
@@ -103,4 +103,19 @@ http {
      proxy_buffer_size 8k;
    }
  }

  server {
    listen <NGINX_STATUS_PORT>;
    server_name localhost;

    access_log off;
    allow <NGINX_STATUS_ALLOW_FROM>;
    deny all;

    location /nginx_status {
      stub_status;
      # ensures the version information can be retrieved
      server_tokens on;
    }
  }
}
+4 −2
Original line number Diff line number Diff line
@@ -2,9 +2,11 @@

set -ex

# nginx.conf doesn't support environment variables,
# so we substitute at run time
# nginx.conf doesn't support environment variables,
# so we substitute at run time
/bin/sed \
  -e "s/<NGINX_STATUS_PORT>/${NGINX_STATUS_PORT:-81}/g" \
  -e "s:<NGINX_STATUS_ALLOW_FROM>:${NGINX_STATUS_ALLOW_FROM:-all}:g" \
  -e "s/<NGINX_PORT>/${NGINX_PORT}/g" \
  -e "s/<APP_HOST>/${APP_HOST:-app}/g" \
  -e "s/<APP_PORT>/${APP_PORT}/g" \