Skip to content

Instantly share code, notes, and snippets.

@twolodzko
Created December 5, 2024 08:22
Show Gist options
  • Save twolodzko/cbbe037c277443167fd40e12afc19f70 to your computer and use it in GitHub Desktop.
Save twolodzko/cbbe037c277443167fd40e12afc19f70 to your computer and use it in GitHub Desktop.
Grafana with Nginx reverse proxy
services:
grafana:
image: grafana/grafana
container_name: grafana
restart: unless-stopped
ports:
- '3000:3000'
networks:
- network
nginx:
image: nginx:latest
container_name: nginx
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
- ./index.html:/usr/share/nginx/html/index.html
ports:
- '80:80'
networks:
- network
networks:
network:
Hello, World!
# NGINX config based on this tutorial:
# https://grafana.com/tutorials/run-grafana-behind-a-proxy/
# This is required to proxy Grafana Live WebSocket connections.
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
root /usr/share/nginx/html;
index index.html index.htm;
location /grafana {
proxy_set_header Host $host;
proxy_pass http://grafana:3000;
rewrite ^/grafana/(.*) /$1 break;
}
# Proxy Grafana Live WebSocket connections.
location /grafana/api/live/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_pass http://grafana:3000;
rewrite ^/grafana/(.*) /$1 break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment