I have followed the instructions provided by Grafana (https://grafana.com/tutorials/run-grafana-behind-a-proxy/#1), but continue to not be successful. Below is my nginx config file. The problem is when I go to http://www.example.com/grafana it redirects me to www.example.com/login which returns 404. Thank you for any assistance!
NGINX Configuration File
server {
listen 80;
listen [::]:80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# Portainer
location /portainer/ {
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://www.example.com:9000/;
}
location /portainer/ws/ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_pass http://www.example.com:9000/ws/;
}
# Grafana
location /grafana/ {
proxy_pass http://www.example.com:3000/;
}
}
Grafana Configuration File
#################################### 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 = example.com
# 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 = true
# Log web requests
;router_logging = false
# the path relative working path
;static_root_path = public
# enable gzip
;enable_gzip = false
# https certs key file
;cert_file =
;cert_key =
# Unix socket path
;socket =
t=2020-10-11T19:50:38+0000 lvl=info msg="Request Completed" logger=context userId=0 orgId=0 uname= method=GET path=/grafana/ status=302 remote_addr=172.17.0.1 time_ms=0 size=29 referer=
– Matt L