I have tried using the grafana proxy-conf which comes default in swag, however I get into a loop when access grafana via reverse proxy. Please could someone help
Here is my config
On Grafana, I’m using environment variable
GF_SERVER_DOMAIN = localhost
GF_SERVER_ROOT_URL = %(protocol)s://%(domain)s:%(http_port)s/grafana/
GF_SERVER_SERVE_FROM_SUB_PATH = true
and this is my proxy-conf for Grafana
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name grafana.*;
include /config/nginx/ssl.conf;
client_max_body_size 0;
# enable for ldap auth, fill in ldap details in ldap.conf
#include /config/nginx/ldap.conf;
# enable for Authelia
#include /config/nginx/authelia-server.conf;
location / {
# enable the next two lines for http auth
#auth_basic "Restricted";
#auth_basic_user_file /config/nginx/.htpasswd;
# enable the next two lines for ldap auth
#auth_request /auth;
#error_page 401 =200 /ldaplogin;
# enable for Authelia
#include /config/nginx/authelia-location.conf;
#include /config/nginx/proxy.conf;
#include /config/nginx/resolver.conf;
set $upstream_app 192.168.1.101;
set $upstream_port 3000;
set $upstream_proto http;
proxy_pass $upstream_proto://$upstream_app:$upstream_port/grafana;
# Clear Authorization Header if you are using http auth and normal Grafana auth
proxy_set_header Authorization "";
}
}
When I try accessing grafana.xxxx.co.in it goes into a loop with this in the address bar https://grafana.xxxx.co.in/?chunkNotFound and a details error message
I tries replacing localhost in grafana domain variable and conf file but gives a 502 gateway error. Any help is really appreciated
I would login to swag and try to ping the different ips you used. I suggest using the docker DNS service. Any you can just use the container name.
Looks like you’ve got two problems:
Grafana is listening on localhost (127.0.0.1), but nginx I assume is the host’s LAN IP (192.168.1.101).
It looks like you took the subdomain example and tried to turn it into a subfolder proxy - there should be a second example file already written for a subfolder. Here’s one I grabbed from a random node running this container; note the location line and the rewrite:
# grafana requires environment variables set thus:
# environment:
# - "GF_SERVER_ROOT_URL=https://my.domain.com/grafana"
# - "GF_SERVER_DOMAIN=https://my.domain.com/"
location ^~ /grafana/ {
# enable the next two lines for http auth
#auth_basic "Restricted";
#auth_basic_user_file /config/nginx/.htpasswd;
# enable the next two lines for ldap auth, also customize and enable ldap.conf in the default conf
#auth_request /auth;
#error_page 401 =200 /ldaplogin;
# enable for Authelia, also enable authelia-server.conf in the default site config
#include /config/nginx/authelia-location.conf;
include /config/nginx/proxy.conf;
include /config/nginx/resolver.conf;
set $upstream_grafana grafana;
set $upstream_port 3000;
set $upstream_proto http;
proxy_pass http://$upstream_grafana:$upstream_port ;
# Clear Authorization Header if you are using http auth and normal Grafana auth
#proxy_set_header Authorization "";
rewrite ^/grafana/(.*)$ /$1 break;
}
Also there’s no server settings because should get pulled into a subdomain setting that has a line like:
include /config/nginx/site-confs/*.subdomain.conf;
Check out the default config for an example.
1 Like
rdotts is right, you should choose between subfolder and subdomain :
You wrote one time
GF_SERVER_ROOT_URL = %(protocol)s://%(domain)s:%(http_port)s/grafana/
(subfolder)
and another time
https://grafana.xxxx.co.in/?chunkNotFound
(subdomain)