简体   繁体   中英

InfluxDb as sublocation behind traefik on localhost using docker, Ubuntu 20.04

since the last two days I am trying to set up a traefik instance which can access the dashboard of my influxdb 2.0 instance via localhost/influx

tl;dr The route is working fine. The problem occurs when the initial request is returned as 200-OK it tries to load some javascript to load the gui and signin page but the sublocation is not present in the request.

Here is what I have:

I have a working traefik instance inside docker using this command:

docker run -d -v /var/run/docker.sock:/var/run/docker.sock:ro -v $PWD/traefik/traefik.toml:/traefik.toml -v $PWD/traefik/traefik_dynamic.toml:/traefik_dynamic.toml -p 80:80 -p 433:433 -p 8080:8080 --network skynet --name traefik traefik:latest

traefik.toml:

[entryPoints]
  [entryPoints.web]
    address = ":80"

[providers.docker]
  endpoint = "unix://var/run/docker.sock"
  network = "skynet"
  watch = true

[api]
  dashboard = true
  insecure = true

[providers.file]
  filename = "traefik_dynamic.toml"

traefik_dynamic.toml file:

  users = [
    "user:pass"
  ]

[http.routers.api]
  rule = "Host(`localhost`)"
  entrypoints = ["web"]
  middlewares = ["simpleAuth"]
  service = "api@internal"

I set up an influx-docker (v2) with this configuration:

docker run -d --name influx --network skynet -v $PWD/config.yml:/etc/influxdb2/config.yml -v $PWD/data:/var/lib/influxdb2 --label-file./traefik_labels influxdb:2.0.4

The config.yml contains no changes, so default.

bolt-path: /var/lib/influxdb2/influxd.bolt
e2e-testing: false
engine-path: /var/lib/influxdb2/engine
feature-flags: {}
http-bind-address: ":8086"
influxql-max-select-buckets: 0
influxql-max-select-point: 0
influxql-max-select-series: 0
key-name: ""
log-level: info
nats-max-payload-bytes: 1048576
nats-port: 4222
no-tasks: false
query-concurrency: 10
query-initial-memory-bytes: 0
query-max-memory-bytes: 0
query-memory-bytes: 9223372036854775807
query-queue-size: 10
reporting-disabled: false
secret-store: bolt
session-length: 60
session-renew-disabled: false
storage-cache-max-memory-size: 1073741824
storage-cache-snapshot-memory-size: 26214400
storage-cache-snapshot-write-cold-duration: 10m0s
storage-compact-full-write-cold-duration: 4h0m0s
storage-compact-throughput-burst: 50331648
storage-max-concurrent-compactions: 0
storage-max-index-log-file-size: 1048576
storage-retention-check-interval: 30m0s
storage-series-file-max-concurrent-snapshot-compactions: 0
storage-series-id-set-cache-size: 0
storage-shard-precreator-advance-period: 30m0s
storage-shard-precreator-check-interval: 10m0s
storage-tsm-use-madv-willneed: false
storage-validate-keys: false
storage-wal-fsync-delay: 0s
store: bolt
testing-always-allow-setup: false
tls-cert: ""
tls-key: ""
tls-min-version: "1.2"
tls-strict-ciphers: false
tracing-type: ""
vault-addr: ""

For the labels file i use:

traefik.enable=true
traefik.http.routers.influx-router.entryPoints=web
traefik.http.routers.influx-router.rule=(`/influx`)
traefik.http.middlewares.influx-strip.stripprefix.prefixes=/influx
traefik.http.routers.influx-router.middlewares=influx-strip@docker

With this configuration I can access the dashboard of traefik on http://localhost in eg Firefox. If I access http://localhost/influx the request is resolvoed fine.

在此处输入图像描述

But the javascript is missing the pathPrefix.

在此处输入图像描述

I already tested to change the http-bind-address to localhost/influx:8086 or traefik/influx:8086. Even "influx/influx:8086" since the host is known in the docker network. The host is never found if I add the sublocation.

The Problem seems to be a recursive issue. If i ommit any bind-address, the influx-instance is listening to localhost/ or::8086. But then it also delivers its urls just with a "/". Since i want to access it via /influx, i have to strip it before the service is request from traefik.

Thats why the first request is working and since the delivered urls are not with the prefix, the following requests are not found/ not parseable by traefik.

I if try to change the bind-address to eg localhost/influx:8086 the influx container tries to reach that host, but since the container is not fully accessible / loaded traefik won't resolve this route and the host is not reachable.

Is there a way to make this work? I tried serveral workarounds with regular expressions but did end up in a redirecting loop;)

Anybody outhere with a kinda working similar setup?

I have the same problem but at the moment there seems no solution available versions > 2. There're a bunch of GitHub issues open regarding this sub-path problem (eg https://github.com/influxdata/influxdb/issues/15721 ).

From what I read there is the option to set a base path in Chronograf <v2 but not in the version in v2. For v2 there only seems to be a compile option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM