From 67f797e8abd962ed731ea111cfa973bea4b667fb Mon Sep 17 00:00:00 2001 From: Waris Lakthong <77393871+spyspoisspuis@users.noreply.github.com> Date: Sat, 30 Mar 2024 21:00:07 +0700 Subject: [PATCH] Config grafana reverse proxy --- docker-compose.dev.yml | 1 + docker-compose.prod.yml | 1 + monitoring/grafana/grafana.ini | 3 +++ monitoring/grafana/grafana.ini.prod | 3 +++ nginx/nginx.dev.conf | 8 ++++++++ nginx/nginx.prod.conf | 8 ++++++++ 6 files changed, 24 insertions(+) create mode 100644 monitoring/grafana/grafana.ini create mode 100644 monitoring/grafana/grafana.ini.prod diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 26140b3..e40d555 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -229,6 +229,7 @@ services: - ./monitoring/grafana/datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml - ./monitoring/grafana/main-dashboard.json:/var/lib/grafana/dashboards/dashboard.json - ./monitoring/grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/main.yml + - ./monitoring/grafana/grafana.ini:/etc/grafana/grafana.ini environment: - GF_AUTH_ANONYMOUS_ENABLED=true - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 24b8f7e..ed6fc69 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -232,6 +232,7 @@ services: - ./monitoring/grafana/datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml - ./monitoring/grafana/main-dashboard.json:/var/lib/grafana/dashboards/dashboard.json - ./monitoring/grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/main.yml + - ./monitoring/grafana/grafana.ini.prod:/etc/grafana/grafana.ini environment: - GF_AUTH_ANONYMOUS_ENABLED=true - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin diff --git a/monitoring/grafana/grafana.ini b/monitoring/grafana/grafana.ini new file mode 100644 index 0000000..ca4950f --- /dev/null +++ b/monitoring/grafana/grafana.ini @@ -0,0 +1,3 @@ +[server] +root_url = http://localhost/grafana +serve_from_sub_path = true \ No newline at end of file diff --git a/monitoring/grafana/grafana.ini.prod b/monitoring/grafana/grafana.ini.prod new file mode 100644 index 0000000..00d8b92 --- /dev/null +++ b/monitoring/grafana/grafana.ini.prod @@ -0,0 +1,3 @@ +[server] +root_url = https://search.dhammanava.net/grafana +serve_from_sub_path = true \ No newline at end of file diff --git a/nginx/nginx.dev.conf b/nginx/nginx.dev.conf index 1a7b978..d2ba0f8 100644 --- a/nginx/nginx.dev.conf +++ b/nginx/nginx.dev.conf @@ -44,5 +44,13 @@ http { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } + + location /grafana/ { + proxy_set_header Host $host; + proxy_pass http://grafana:3000; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } } } \ No newline at end of file diff --git a/nginx/nginx.prod.conf b/nginx/nginx.prod.conf index 2fbc2ca..26119a0 100644 --- a/nginx/nginx.prod.conf +++ b/nginx/nginx.prod.conf @@ -65,6 +65,14 @@ http { proxy_set_header X-Forwarded-Proto $scheme; } + location /grafana/ { + proxy_set_header Host $host; + proxy_pass http://grafana:3000; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + location ~ /.well-known/acme-challenge/ { root /var/www/certbot; }