Grafana and nginx reverse proxy with docker

I use docker to deploy Grafana v4.4.1 and Nginx v1.13.1 on different server. the Nginx server is 10.88.142.19, and the Grafana server is 10.88.142.20

My nginx conf like that:
upstream grafana {
server 10.88.142.20:3000;
}
server {
listen 80;
location /grafana/ {
proxy_pass http://grafana/;
}
}

My grafana conf in compose.yaml like that:
grafana:
image: grafana/grafana:4.4.1
ports:
- "3000:3000"
environment:
GF_SECURITY_ADMIN_PASSWORD: 'devops’
GF_SERVER_ROOT_URL: ‘%(protocol)s://10.88.142.20/grafana’

When I access the url ‘http://10.88.142.19/grafana’ in browser on my laptop, only the black screen in browser window, no login page and anything else. And the grafana log does not output anything. The last output is ‘t=2017-07-14T06:18:20+0000 lvl=info msg=“Initializing HTTP Server” logger=http.server address=0.0.0.0:3000 protocol=http subUrl=/grafana socket=’

try setting GF_SERVER_ROOT_URL to http://10.88.142.19/grafana

Thanks your reply. But it doesn’t work.

I found if I don’t use the subpath, and followed the office docs, everything is OK.
It seems subpath maybe have some issues is Grafana

Thousands use subpath & nginx as a reverse proxy without issue so it must be a config issue you’re experiencing

In my case the following configuration works.
Dummy public URL is https://mydomain.com/grafana.

upstream grafana {
  server 10.10.10.5:3000;
}

server {
  location /grafana {
    proxy_pass http://grafana;
    rewrite  ^/grafana/(.*)  /$1 break;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    include proxy_params;
  }
}

In docker-compose.yml:

services:
  grafana:
    #...
    environment:
      - GF_SERVER_ROOT_URL=https://mydomain.com/grafana