Skip to content

Instantly share code, notes, and snippets.

@Gummibeer
Created December 7, 2017 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Gummibeer/12b55438e36009206bdc939159775706 to your computer and use it in GitHub Desktop.
Save Gummibeer/12b55438e36009206bdc939159775706 to your computer and use it in GitHub Desktop.
Install vts module on nginx

nginx.conf

http {
  vhost_traffic_status_zone;
  vhost_traffic_status_dump /var/log/nginx/vts.db;
}

vhost.conf

server {
  if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") {
    set $year $1;
    set $month $2;
    set $day $3;
  }

  vhost_traffic_status_filter_by_set_key $year year::$server_name;
  vhost_traffic_status_filter_by_set_key $year-$month month::$server_name;
  vhost_traffic_status_filter_by_set_key $year-$month-$day day::$server_name;

  location /nginx-status {
    vhost_traffic_status_bypass_limit on;
    vhost_traffic_status_bypass_stats on;
    vhost_traffic_status_display;
    vhost_traffic_status_display_format html;
    allow 127.0.0.1;
    deny all;
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment