Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using root path on admin UI v2 #5352

Closed
seblu opened this issue Jan 14, 2016 · 10 comments
Closed

Avoid using root path on admin UI v2 #5352

seblu opened this issue Jan 14, 2016 · 10 comments

Comments

@seblu
Copy link

seblu commented Jan 14, 2016

The is a follow up of #1236 for influxdb 0.9.6.1 because it's asked to open a new one.

I'm testing a simple reverse-proxy config with nginx and influxdb admin on an Arch Linux system.

Relevant nginx configuration is:

        location /influxdb {
            proxy_pass http://127.0.0.1:8083/;
            proxy_redirect off;
            proxy_ssl_session_reuse off;
            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;
        }

Relevant influxdb config

[http]
  enabled = true
  bind-address = "localhost:8086"
  auth-enabled = true
  log-enabled = true
  write-tracing = false
  pprof-enabled = false
  https-enabled = false
  https-certificate = "/etc/ssl/influxdb.pem"

[admin]
  enabled = true
  bind-address = "localhost:8083"
  https-enabled = false

The web admin interface is almost displayed correctly except the database dropdown menu.

But the admin interface use http://localhost:8086/query?q=SHOW+DATABASES&db= to execute query instead of $relative/query?....

We seems to be close to have this to work.

@mvadu
Copy link
Contributor

mvadu commented Feb 27, 2016

+1

I am trying to run both grafana and influxdb behind a server. We can only listen on port 80. Below is my nginx config:

        # proxy grafana 
        location /apm/ {
            access_log logs/grafana-access.log grafana;
            proxy_pass http://localhost:3000/;
            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_cache grafana_cache;
            proxy_cache_min_uses 1;
            proxy_cache_valid 200 302 5m;
            proxy_cache_valid 404 1m;
            add_header X-Cache-Status $upstream_cache_status;
        }

        #proxy influxDB
        location /influxdb {
            proxy_pass http://localhost:8083/;
            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_max_temp_file_size 0;
            proxy_connect_timeout      240;
            proxy_send_timeout         240;
            proxy_read_timeout         240;
            expires -1;
            add_header Cache-Control private;
        }

Using latest code I am not able to get basic UI. My redirect is correct as grafana works just fine.

image

@mvadu
Copy link
Contributor

mvadu commented Mar 16, 2016

I was able to handle both root path issue (for static content) and hard coded API path (always server:port/ping, server:port:query etc) issues via a complicated nginx config shared here.

@ProTip
Copy link

ProTip commented Aug 17, 2016

@mvadu How were you able to get the admin UI to make query requests back on the same port?

@mvadu
Copy link
Contributor

mvadu commented Aug 18, 2016

@ProTip take a look at the nginx config
I created a map on the incoming request referrer header

##################################Maps to detect Influx hardcoded traffic############################
    #check the referer to identify requests originated by Influx Web UI
    map $http_referer $proxyloc {   
        ~*influx influx;
    }

This basically creates a Boolean which gets set for all requests originated from WebUI (all java scripts, css etc). I then check this in the request processing for default location (as the WebUI defaults to the root, all requests come to this location)

###################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;
            }
        }

This results in a HTTP 302 redirect responses for these requests with URI changed to /influx/. When browser uses the redirect, it gets processed by the location handler, which passes the request to Influxdb server, and the final response is returned.

Long story short, this results in a 2 round trips for each request to InfluxDB via NginX instead of one. Please go through the config file, and you can follow it I suppose.

@stromnet
Copy link

stromnet commented Sep 8, 2016

Just want to give this issue a thumbs up, I have problems with this as well as I have a setup where direct access is not possible, and it must go through an existing web proxy (which unfortunately isn't nginx so the above magic solutions won't help).

@curry684
Copy link

I've actually got it to work pretty easy with some hacking. I launched Influx 1.0 through Docker and exposed the proper ports, then used this in Nginx:

    location /influx/ {
        proxy_pass http://influxdb:8083/;
        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_redirect off;
    }
    location /influx-api/ {
        proxy_pass http://influxdb:8086/;
        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_redirect off;
    }

The bad part now it that the web admin is reachable on /influx but broken because the API root path is not configurable itself anywhere. The good part is there's no input validation whatsoever on the configuration, so you can just enter 80/influx-api for the port, and afaics everything works fine from there.

So please, input validation on the port configuration is a good idea, but don't do it before you've exposed the API root path in config 😄

Also I would really like to preconfigure all those config values (host, port, path, credentials) from env variables as they're constants anyway in a Docker Compose setup.

@curry684
Copy link

How was this closed? There are no linked issues so how was this implemented now?

@mvadu
Copy link
Contributor

mvadu commented Nov 17, 2016

@curry684 as per latest release notes v1.1 deprecates admin UI itself. Hence @jwilder is pruning all issues related to admin UI.

@curry684
Copy link

Ah ok, I'll just add a quick&dirty dev panel to my own tools then, I found the admin UI pretty useful during development for finetuning queries, as task for which Grafana is just too unwieldy. But in the end it's just a text field and a formatted table anyway.

@monsdar
Copy link

monsdar commented Mar 10, 2021

Btw this seems to be the issue where its discussed to add a proper way for custom subpathes in InfluxDB2: #15721

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants