I struggled a bit with all the answers here. For completeness and documentation for myself a full example which worked in my case.
/etc/grafana/grafana.ini
:
... DEFAULT CONFIGURATION
#################################### Server ################################
... DEFAULT CONFIGURATION
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/
... DEFAULT CONFIGURATION
nginx.conf
looks like this:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
#
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
... DEFAULT SETTINGS ...
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
# note that I am not using sites-enabled:
# include /etc/nginx/sites-enabled/*;
}
I put the NGINX configuration for grafana into a separate grafana.conf
located in /etc/nginx/conf.d/
:
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
root /var/www/<my.hostname.xy>/html;
index index.html index.htm;
server_name <my.hostname.xy>;
location /grafana/ {
proxy_pass http://localhost:3000/;
proxy_set_header Host $host;
}
}