-
Notifications
You must be signed in to change notification settings - Fork 1
Running behind nginx
To pass netdata via a nginx, use this:
upstream backend {
# the netdata server
server 127.0.0.1:19999;
keepalive 64;
}
server {
# nginx listens to this
listen 80;
# the virtual host name of this
server_name netdata.example.com;
location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_pass_request_headers on;
proxy_set_header Connection "keep-alive";
proxy_store off;
}
}
upstream netdata {
server 127.0.0.1:19999;
keepalive 64;
}
server {
listen 80;
# the virtual host name of this subfolder should be exposed
#server_name netdata.example.com;
location = /netdata {
return 301 /netdata/;
}
location ~ /netdata/(?<ndpath>.*) {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_pass_request_headers on;
proxy_set_header Connection "keep-alive";
proxy_store off;
proxy_pass http://netdata/$ndpath$is_args$args;
gzip on;
gzip_proxied any;
gzip_types *;
}
}
upstream backend-server1 {
server 10.1.1.103:19999;
keepalive 64;
}
upstream backend-server2 {
server 10.1.1.104:19999;
keepalive 64;
}
server {
listen 80;
# the virtual host name of this subfolder should be exposed
#server_name netdata.example.com;
location ~ /netdata/(?<behost>.*)/(?<ndpath>.*) {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_pass_request_headers on;
proxy_set_header Connection "keep-alive";
proxy_store off;
proxy_pass http://backend-$behost/$ndpath$is_args$args;
gzip on;
gzip_proxied any;
gzip_types *;
}
# make sure there is a trailing slash at the browser
# or the URLs will be wrong
location ~ /netdata/(?<behost>.*) {
return 301 /netdata/$behost/;
}
}
Of course you can add as many backend servers as you like.
Using the above, you access netdata on the backend servers, like this:
-
http://nginx.server/netdata/server1/to reachbackend-server1 -
http://nginx.server/netdata/server2/to reachbackend-server2
Create an authentication file to enable the nginx basic authentication. Do not use authentication without SSL/TLS! If you haven't one you can do the following:
printf "yourusername:$(openssl passwd -apr1)" > /etc/nginx/passwords
And enable the authentication inside your server directive:
server {
# ...
auth_basic "Protected";
auth_basic_user_file passwords;
# ...
}
If your nginx is on localhost, you can use this to protect your netdata:
[web]
bind to = 127.0.0.1 ::1
You can also use a unix domain socket. This will also provide a faster route between nginx and netdata:
[web]
bind to = unix:/tmp/netdata.sock
note: netdata v1.8+ support unix domain sockets
At the nginx side, use something like this to use the same unix domain socket:
upstream backend {
server unix:/tmp/netdata.sock;
keepalive 64;
}
If your nginx server is not on localhost, you can set:
[web]
bind to = *
allow connections from = IP_OF_NGINX_SERVER
note: netdata v1.9+ support allow connections from
allow connections from accepts netdata simple patterns to match against the connection IP address.
nginx logs accesses and netdata logs them too. You can prevent netdata from generating its access log, by setting this in /etc/netdata/netdata.conf:
[global]
access log = none
If you get an 502 Bad Gateway error you might check your nginx error log:
# cat /var/log/nginx/error.log:
2016/09/09 12:34:05 [crit] 5731#5731: *1 connect() to 127.0.0.1:19999 failed (13: Permission denied) while connecting to upstream, client: 1.2.3.4, server: netdata.example.com, request: "GET / HTTP/2.0", upstream: "http://127.0.0.1:19999/", host: "netdata.example.com"If you see something like the above, chances are high that SELinux prevents nginx from connecting to the backend server. To fix that, just use this policy: setsebool -P httpd_can_network_connect true.
General
- Home
- Why netdata
- Installation
- Installation with docker
- Command Line Options
- Configuration
- Log Files
- Tracing Options
Running Netdata
Special Uses
-
netdata for IoT
lower netdata resource utilization -
high performance netdata
netdata public on the internet
Notes on memory management
-
Memory deduplication
half netdata memory requirements - netdata virtual memory size
Database Replication and Mirroring
- Replication Overview
-
monitoring ephemeral nodes
Use netdata to monitor auto-scaled cloud servers. -
netdata proxies
Streaming netdata metrics between netdata servers.
Backends
archiving netdata collected metrics to a time-series database
-
netdata-backends
graphite,opentsdb,kairosdb,influxdb,elasticsearch,blueflood - netdata with prometheus
- Walk Through: netdata with prometheus and grafana
Health monitoring - Alarms
alarms and alarm notifications in netdata
- Overview
-
Reference
reference for writing alarms -
Examples
simple how-to for writing alarms -
Notifications Configuration
- health API calls
- troubleshooting alarms
Netdata Registry
Monitoring Info
-
Monitoring web servers
The spectacles of a web server log file -
monitoring ephemeral containers
Use netdata to monitor auto-scaled containers. - monitoring systemd services
-
monitoring cgroups
Use netdata to monitor containers and virtual machines. -
monitoring IPMI
Use netdata to monitor enterprise server hardware - Monitoring disks
- Monitoring Go Applications
Netdata Badges
Data Collection
- Add more charts to netdata
- Internal Plugins
- External Plugins
-
statsd
netdata is a fully featured statsd server -
Third Party Plugins
netdata plugins distributed by third parties
Binary Modules
Python Modules
- How to write new module
- apache
- beanstalk
- bind_rndc
- ceph
- couchdb
- cpuidle
- cpufreq
- dns_query_time
- dovecot
- elasticsearch
- exim
- fail2ban
- freeradius
- go_expvar
- haproxy
- hddtemp
- httpcheck
- icecast
- ipfs
- isc_dhcpd
- litespeed
- mdstat
- megacli
- memcached
- mongodb
- mysql
- nginx
- nginx_plus
- nsd
- ntpd
- ovpn_status_log
- phpfpm
- portcheck
- postfix
- postgres
- powerdns
- puppet
- rabbitmq
- redis
- rethinkdbs
- retroshare
- sensors
- spigotmc
- springboot
- squid
- smartd_log
- tomcat
- traefik
- unbound
- varnish
- w1sensor
- web_log
Node.js Modules
BASH Modules
Active BASH Modules
Obsolete BASH Modules
- apache
- cpufreq
- cpu_apps
- exim
- hddtemp
- load_average
- mem_apps
- mysql
- nginx
- phpfpm
- postfix
- sensors
- squid
- tomcat
API Documentation
Web Dashboards
-
Learn how to create dashboards with charts from one or more netdata servers!
Running behind another web server
Package Maintainers
Donations
Blog
-
December, 2016
Linux console tools, fail to report per process CPU usage properly
-
April, 2016
You should install QoS on all your servers (Linux QoS for humans)
Monitor application bandwidth with Linux QoS (Good to do it, anyway)
Monitoring SYNPROXY (Linux TCP Anti-DDoS)
-
March, 2016
Article: Introducing netdata (the design principles of netdata)