Last active
          January 19, 2025 13:38 
        
      - 
      
- 
        Save mvadu/5fbb7f5676ce31f2b1e6 to your computer and use it in GitHub Desktop. 
Revisions
- 
        mvadu revised this gist Oct 5, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -78,7 +78,7 @@ http { server { listen 80; server_name grafana.adystech.com; ############################### proxy grafana################################################### location /grafana/ { 
- 
        mvadu revised this gist Oct 5, 2016 . 1 changed file with 9 additions and 9 deletions.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #user nobody worker_processes 1; error_log /var/log/nginx/error.log warn; events { worker_connections 1024; @@ -78,7 +78,7 @@ http { server { listen 80; server_name pacelab.cognizant.com; ############################### proxy grafana################################################### location /grafana/ { @@ -92,7 +92,7 @@ http { proxy_http_version 1.1; proxy_set_header Connection ""; access_log /var/log/nginx/grafana-access.log grafana buffer=1024 flush=5m; proxy_pass http://grafana/; proxy_redirect default; @@ -116,7 +116,7 @@ http { auth_basic_user_file influx.conf; root /inflx/; access_log /var/log/nginx/influx-access.log influx buffer=1024 flush=5m; proxy_pass http://influx/; proxy_redirect default; proxy_set_header Host $host; @@ -152,7 +152,7 @@ http { auth_basic_user_file influx.conf; root /influxdb/; access_log /var/log/nginx/influx-access.log influx buffer=1024 flush=5m; proxy_pass http://influxdb/; proxy_redirect default; proxy_http_version 1.1; @@ -174,13 +174,13 @@ http { ###################Default location also handles the Influx redirects########################### location /{ if ($backend) { return 302 /$backend/$request_uri; } if ($proxyloc) { return 302 /$proxyloc/$uri; } return 302 /grafana/; } ################################################################################################ } 
- 
        mvadu revised this gist Mar 24, 2016 . 1 changed file with 25 additions and 12 deletions.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -49,6 +49,12 @@ http { ~*write influxdb; ~*ping influxdb; } #We will enable caching for only queries, not for regular UI pages of grafana map $request_uri $nonquery { ~*query 0; default 1; } ##################################################################################################### ######################################Upstream servers############################################### @@ -76,23 +82,30 @@ http { ############################### proxy grafana################################################### location /grafana/ { proxy_buffering on; proxy_buffers 8 128k; proxy_buffer_size 128k; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_set_header Connection ""; access_log logs/grafana-access.log grafana buffer=1024 flush=5m; proxy_pass http://grafana/; proxy_redirect default; proxy_cache_key "$request_uri"; proxy_cache_min_uses 1; proxy_cache grafana_cache; proxy_cache_bypass $nonquery; proxy_cache_valid 200 302 120s; proxy_cache_valid 404 1m; add_header X-Cache-Status $upstream_cache_status; #proxy_cache_key $proxy_host$request$cookie_grafanasess; #proxy_ignore_headers X-Accel-Expires Expires Cache-Control; } ################################################################################################ 
- 
        mvadu created this gist Mar 16, 2016 .There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ # The full public facing url #root_url = %(protocol)s://%(domain)s:%(http_port)s/ root_url = http://localhost:80/grafana/ This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,174 @@ #user nobody; worker_processes 1; error_log logs/error.log warn; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #gzip setup gzip on; gzip_http_version 1.1; gzip_vary on; gzip_comp_level 6; gzip_proxied any; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js; gzip_buffers 16 8k; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; server_tokens off; #log formats log_format grafana '$time_iso8601 $remote_addr - $remote_user $proxy_host$request$cookie_grafanasess "$request" $status $body_bytes_sent $request_time' ; log_format influx '$time_iso8601 $remote_addr - $remote_user "$scheme://$server_name/$uri" $status $body_bytes_sent $request_time' ; #proxy cache formats proxy_cache_path temp/grafana_cache levels=1:2 keys_zone=grafana_cache:25m max_size=500m inactive=5m use_temp_path=off; proxy_cache_path temp/influx_cache levels=1:2 keys_zone=influx_cache:25m max_size=50m inactive=15m use_temp_path=off; ##################################Maps to detect Influx hardcoded traffic############################ #check the referer to identify requests originated by Influx Web UI map $http_referer $proxyloc { ~*influx influx; } #Influx Web API end points map $request_uri $backend { ~*query influxdb; ~*write influxdb; ~*ping influxdb; } ##################################################################################################### ######################################Upstream servers############################################### upstream grafana { server localhost:3000; keepalive 15; } upstream influx { server localhost:8083; keepalive 10; } upstream influxdb { server localhost:8086; keepalive 10; } ##################################################################################################### server { listen 80; server_name graflux.adystech.com; ############################### proxy grafana################################################### location /grafana/ { access_log logs/grafana-access.log grafana buffer=1024 flush=5m; proxy_pass http://grafana/; proxy_redirect default; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_cache grafana_cache; proxy_cache_key $proxy_host$request$cookie_grafanasess; proxy_cache_min_uses 2; #proxy_cache_valid 200 302 30s; #proxy_cache_valid 404 1m; add_header X-Cache-Status $upstream_cache_status; } ################################################################################################ ############################### proxy influx db################################################# #proxy influxDB location /influx/ { auth_basic "Needs Autherization to visit"; auth_basic_user_file influx.conf; root /inflx/; access_log logs/influx-access.log influx buffer=1024 flush=5m; proxy_pass http://influx/; proxy_redirect default; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Authorization ""; #for keep alive to work proxy_http_version 1.1; proxy_set_header Connection ""; #handle upstream timeout proxy_max_temp_file_size 0; proxy_connect_timeout 240; proxy_send_timeout 240; proxy_read_timeout 240; #cache the static content expires 1d; add_header Pragma public; add_header Cache-Control "public"; #cahce dynamic data proxy_cache influx_cache; proxy_cache_min_uses 1; proxy_cache_valid 200 302 30s; proxy_cache_valid 404 1m; add_header X-Cache-Status $upstream_cache_status; } location /influxdb/ { auth_basic "Needs Autherization to visit"; auth_basic_user_file influx.conf; root /influxdb/; access_log logs/influx-access.log influx buffer=1024 flush=5m; proxy_pass http://influxdb/; proxy_redirect default; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_set_header Authorization ""; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_max_temp_file_size 0; proxy_connect_timeout 240; proxy_send_timeout 240; proxy_read_timeout 240; expires -1; add_header Cache-Control private; } ################################################################################################ ###################Default location also handles the Influx redirects########################### location /{ if ($backend) { return 302 https://$server_name/$backend/$request_uri; } if ($proxyloc) { return 302 https://$server_name/$proxyloc/$uri; } return $scheme://$server_name/apm/; } ################################################################################################ } } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ This config will enable Nginx to listen on port 80, and act as a reverse proxy for grafana (refer to the custom ini root_url section below), and Influx DB. Influx DB has a problem where it is using root path on admin UII (refer [issue#5352](https://github.com/influxdata/influxdb/issues/5352)) and this config handles it via referrer and api end point redirects.