grafana預設跑在3000的port上
要讓nginx可以upstream到grafana上
並不能只是在nginx上設定
grafana的init設定檔 也需要對應設定
為了讓我們方便管理
可以透過 ansible 將本機準備好的grafana.ini丟到遠端主機上
再透過docker volumn對應 將這ini檔案 對應到container內設定檔的位置
docker-compose 設定
version: '3.8'
services:
grafana:
image: grafana/grafana
container_name: grafana99
restart: always
volumes:
- grafana_data:/var/lib/grafana
- /home/ozzy/docker_share/monitor/grafana.ini:/etc/grafana/grafana.ini:ro
environment:
- GF_SECURITY_ADMIN_PASSWORD=xxxx
depends_on:
- prometheus
ports:
- '3000:3000'
grafana.ini設定
instance_name = ozzysun.com
protocol = http
http_port = 3000
domain = ozzysun.com
enforce_domain = true
root_url = http://ozzysun.com/grafana
serve_from_sub_path = true
nginx端設定location /grafana/ {
proxy_pass http://192.168.0.99:3000;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}