Skip to content

Instantly share code, notes, and snippets.

@JohnnyQQQQ
Created May 16, 2023 08:15
Show Gist options
  • Save JohnnyQQQQ/ff9241cf838acaa054fdec49bef9f419 to your computer and use it in GitHub Desktop.
Save JohnnyQQQQ/ff9241cf838acaa054fdec49bef9f419 to your computer and use it in GitHub Desktop.
Grafana with reverse proxy
version: '3.8'
services:
grafana:
image: grafana/grafana:main
container_name: grafana
restart: always
ports:
- "3000:3000"
networks:
- grafana_net
environment:
- GF_SERVER_ROOT_URL=http://localhost:8081/grafana/
- GF_SERVER_SERVE_FROM_SUB_PATH=true
nginx:
image: nginx:latest
container_name: nginx
restart: always
ports:
- "8081:8081"
networks:
- grafana_net
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
depends_on:
- grafana
networks:
grafana_net:
driver: bridge
worker_processes 1;
events { worker_connections 1024; }
http {
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream grafana {
server grafana:3000;
}
server {
listen 8081;
root /usr/share/nginx/www;
index index.html index.htm;
location /grafana/ {
rewrite ^/grafana/(.*) /$1 break;
proxy_set_header Host $http_host;
proxy_pass http://grafana/;
}
# 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;
}
}
}
@torkelo
Copy link

torkelo commented May 17, 2023

@JohnnyQQQQ either remove the rewrite or remove the serve_from_sub_path flag , having both causes issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment