Configure Nginx Reverse Proxy For Grafana Access

Published on Author gryzli

Proxying Grafana with Nginx is easy, but there are some small thins that needs to be considered.

If you have already tried this and received strange errors like:

192.168.1.1 – – [09/May/2019:10:26:58 +0300] “-” 000 0 “-” “-” “-“

or

499 errors in your nginx proxy logs

or

Grafana dashboard graphics not being loaded

most probably you have forgotten the tricky Nginx  variables mentioned below.

1) Configure Grafana

These are the important settings inside grafana.ini you need to setup properly:

Open grafana config file: /etc/grafana/grafana.ini

 

2) Configure Nginx

This is the tricky part from the setup. If you forget to put the header buffer settings in your Nginx vhost configs, you will end up with malfunctioning Grafana graphs.

The key parts from your Nginx configs are the usage of:

large_client_header_buffers

AND (for http2 over ssl, if you are using it)

http2_max_header_size

http2_max_field_size

 

In the SSL vhost configuration I expect you have put your SSL certificates under:

ssl_certificate “/etc/pki/tls/certs/graf.example.com.crt”;

ssl_certificate_key “/etc/pki/tls/private/graf.example.com.key”;

Modify it to suite your case.

 

3) Some more information on Nginx Proxying

If you are interested in some more useful information regarding Nginx proxying (with caching), I’ve written some resources about it. Check it out. 

How To Setup Nginx Reverse Proxy With Caching

Nginx Proxy Caching based on page size  

Check If Request is being cached in Nginx