-
What Grafana version and what operating system are you using?
OS: Red Hat Enterprise Linux 8.6
Grafana version: 9.4.3 -
What are you trying to achieve?
I’m trying to expose Grafana @ http://my_domain/grafana -
How are you trying to achieve it?
I’m trying to use Nginx to expose Grafana -
What happened?
It seems like the configuration does not work.
When I enter the browser at http://my_domain/grafana I am redirected to http://my_domain/login and a 404 Nginx error appears.
Also from logs I’m seeing errors attached below.
In case I enter http://my_domain/grafana/login in the browser, I land to this page:
-
What did you expect to happen?
To reach the Grafana login page. -
Can you copy/paste the configuration(s) that you are having problems with?
Nginx config:
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream grafana {
server community.grafana.com;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/grafana/;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
location /grafana/ {
rewrite ^/grafana/(.*) /$1 break;
# proxy_set_header Host $http_host;
proxy_pass http://grafana;
include /etc/nginx/proxy.conf;
}
# Proxy Grafana Live WebSocket connections.
location /grafana/api/live/ {
rewrite ^/grafana/(.*) /$1 break;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $http_host;
proxy_pass http://grafana;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
Grafana config:
#################################### Server ####################################
[server]
# Protocol (http, https, h2, socket)
;protocol = http
# The ip address to bind to, empty will bind to all interfaces
;http_addr =
# The http port to use
;http_port = 3000
# The public facing domain name used to access grafana from a browser
;domain = localhost
# Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks
;enforce_domain = false
# The full public facing url you use in browser, used for redirects and emails
# If you use reverse proxy and sub path specify full url (with sub path)
;root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/
# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons.
;serve_from_sub_path = false
# Log web requests
;router_logging = true
# the path relative working path
;static_root_path = public
# enable gzip
;enable_gzip = false
# https certs & key file
;cert_file =
;cert_key =
# Unix socket gid
# Changing the gid of a file without privileges requires that the target group is in the group of the process and that the process is the file owner
# It is recommended to set the gid as http server user gid
# Not set when the value is -1
;socket_gid =
# Unix socket mode
;socket_mode =
# Unix socket path
;socket =
# CDN Url
;cdn_url =
# Sets the maximum time using a duration format (5s/5m/5ms) before timing out read of an incoming request and closing idle connections.
# `0` means there is no timeout for reading the request.
;read_timeout = 0
- Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
Error from Nginx logs:
3.122.88.128 - - [13/Mar/2023:09:53:09 +0000] "GET /grafana/ HTTP/1.1" 302 29 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0" "-"
3.122.88.128 - - [13/Mar/2023:09:53:09 +0000] "GET /login HTTP/1.1" 404 169 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0" "-"
3.122.88.128 - - [13/Mar/2023:09:53:09 +0000] "GET /favicon.ico HTTP/1.1" 404 169 "http://datalab/login" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0" "-"
- Did you follow any online instructions? If so, what is the URL?
Yes, I followed the doc: Run Grafana behind a reverse proxy | Grafana Labs