Created
May 16, 2023 08:15
-
-
Save JohnnyQQQQ/ff9241cf838acaa054fdec49bef9f419 to your computer and use it in GitHub Desktop.
Grafana with reverse proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@JohnnyQQQQ either remove the rewrite or remove the serve_from_sub_path flag , having both causes issues