Grafana behind ngnix

Hi all ,
I installed ngnix and configured as shown in your reference (Run Grafana behind a reverse proxy | Grafana Labs)

I also added CORS allow origin as shown in this snippet:

server {
listen       80 default_server;
listen       [::]:80 default_server;
server_name  _;
root         /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
index index.html index.htm;


  location / {

    proxy_pass http://grafana.staged-by-discourse.com/;
    add_header 'Access-Control-Allow-Origin' "*";
    add_header 'Access-Control-Allow-Credentials' 'true' always;
    add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
    add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-
        Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;

    add_header 'Content-Type' 'text/html charset=UTF-8';
    proxy_set_header    Host            $host;
    proxy_set_header    X-Real-IP       $remote_addr;
    proxy_set_header    X-Forwarded-for $remote_addr;
    port_in_redirect off;
    proxy_redirect  off;
    proxy_connect_timeout 300;
    }


    error_page 404 /404.html;
       location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
       location = /50x.html {
    }

}

In my grafana.ini I have setted this:
[server]
domain =server.name.lan
root_url = %(protocol)s://%(domain)s:%(http_port)s/

But when I try to connect to server.name.lan(:80) I got:

If you’re seeing this Grafana has failed to load its application files

  1. This could be caused by your reverse proxy settings.

  2. If you host grafana under subpath make sure your grafana.ini root_path setting includes subpath

  3. If you have a local dev build make sure you build frontend using: npm run dev, npm run watch, or npm run build

  4. Sometimes restarting grafana-server can help

Do you have any clue?

1 Like