-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
influxDB2.0 alpha - http custom base path #15721
Comments
looking at the code systemd...
also seems that the option is in Chronograf looking at the readme
perhaps this should be made available on |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
please provide some feedback before closing. |
For the base path parameters.. those are for configuring the frontend during compilation to allow it to be run behind a proxy, so they're already baked in by the time the image is pushed to the registry. Here's an example dockerfile that I use when i want to expose the frontend on a different url, passing those environment variables as build ARGs: FROM ubuntu:bionic AS base
RUN apt-get update -y && \
apt-get install -y \
nginx \
build-essential \
curl \
git
FROM base AS repo
WORKDIR /repo
ARG STATIC_DIRECTORY
ARG BASE_PATH
ARG API_BASE_PATH
ENV PATH="/node/bin:${PATH}"
RUN mkdir /node && \
curl -sL https://git.io/n-install | N_PREFIX=/node bash -s -- -q && \
npm i -g yarn
RUN git clone git://github.com/influxdata/influxdb.git && \
cd ./influxdb
WORKDIR /repo/influxdb/ui
# these are all run together as docker's caching mechanism
# makes big steps like yarn install expensive
RUN yarn install --production=false && \
yarn generate && \
INFLUXDB_SHA=remote $(npm bin)/webpack --config ./webpack.prod.ts --bail && \
rm -rf ./node_modules
FROM base AS deploy
WORKDIR /repo
COPY --from=repo /repo/influxdb/ui/build /usr/share/nginx/html
COPY ./nginx.conf /etc/nginx/nginx.conf
RUN useradd --no-create-home nginx
CMD ["nginx", "-g", "daemon off;"] with just a simple nginx config in
|
Rebuilding the UI with a variable seems not to be a solution. Setting an environment variable to override the |
Having a similar issue. My setup is:
server conf:
As said, my current configuration seems to load the login page fine, but it's unfunctional as it doesn't allow me access it. Note: I use the docker container for influxdb2.0 beta from https://quay.io/repository/influxdb/influxdb?tag=2.0.0-beta&tab=tags |
Similar issue! Grrrrrr! |
Is there any progress on this? I would really like to put Influx 2 OSS behind a reversproxy. |
Same happening here, can't reverse proxy Influx 2.0. Even after many hours trying with apache html proxy for rewriting urls I can't get it working. |
For people that had the same issue I did (commented a few months ago). Sample nginx configuration: server {
server_name mysubdomain.mydomain.com;
location / {
#access_log /var/log/nginx/influx-access.log influx buffer=1024 flush=5m;
proxy_pass http://localhost:xxxx/;
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;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/mysubdomain.mydomain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mysubdomain.mydomain.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
[...] # Other conf stuff
|
seems the only solution to date is recompiling the source code because the path is baked in.
Guess i'll just continue to ignore the influx UI and use the CLI for the odd admin task. Grafana runing under a custom base url is working out well for viewing data and setting alerts. |
Having the same issue... I just spent about 4 hours on it before finding this thread... For now I think I'll have to go with subdomain as no matter how I mess with the nginx config even if I get some web pages to load, some network requests just won't... |
Chiming in to put a bit more weight onto this issue. I've also just stumbled across this issue when trying to find a solution for the past hours. I wonder why this isn't troublesome for more people, using a reverse proxy with a custom subpath seems to be kind of a standard. |
Spend few days on this issue. So far it seems unresolvable without using subdomain for host based filtering in Ingress. I needed to use InfluxDB UI behing nginx reverse proxy. With only one ingress-controller for the whole cluster. Turns out path based routing is possible with rewrite-target annotation in Ingress resource. But the Influx UI does not display at all. What ultimately cancelled any effort to use Ingress was that We would welcome any customization of base_href path, possibly via helm chart as we're using that for deployment. One option could be to separate INFLUXD_HTTP_BIND_ADDRESS responsibility to server as address to InfluxDB API. And some other ENV_VAR would be responsible for settings path for Influx UI. It would have to be customizable via helm chart as well. |
Having the same issue, spent almost a day finding a solution with trying out different configs. finally, I am here :)
@ondrej-ivanko I hope what you mean is, you could access the influx DB API endpoints(write and query) using the path-based routing approach. but no luck in accessing UI. If that's true can you share the working config with rewrite-target annotation? |
@gvasanka I can't confirm that accessing API endpoints with
Our company decided to abandon the effort to use Ingress controller. We just use port-forwarding of Influx pod for accessing UI. |
@ondrej-ivanko Thank you very much for your answer. I was able to get access to influxDb 2 API with the below Ingress config. Posting it here for other's usage in case somebody struggling.
But still no luck in getting access to the web. |
How is this not receiving more attention? Please can we get acknowledgement of the issue and get ENV access to set the base path like grafana has or appending to request url like even simple containers like adminer has. Apologies if I sound crass but having this hardcoded in is ridiculous. Running behind a reverse proxy nginx is something many people do and having to setup a subdomain just to workaround a HARDCODED base url is really silly. Please try and give us some real commitment on this guys! |
I have a similar issue! |
Would like to also add my complaint to this thread. Grafana has a root_url parameter you can set in the config file. As far as I can tell, that is not the case with InfluxDB. Very frustrating that there appears to be no way for it to reside behind a reverse proxy without a subdomain. |
I would also need this feature, as i dont want to use a second subdomain for this. |
+1 |
This is solution based on version: "3.9"
name: traefik-influxdb
services:
influxdb:
image: influxdb:2.6.1
expose:
- 8086
labels:
traefik.enable: "true"
traefik.http.middlewares.influxdb_strip.stripprefix.prefixes: /influxdb
traefik.http.middlewares.rewrite-foo.plugin.rewrite.lastModified: "true"
traefik.http.middlewares.rewrite-foo.plugin.rewrite.rewrites[0].regex: src="/
traefik.http.middlewares.rewrite-foo.plugin.rewrite.rewrites[0].replacement: src="/influxdb/
traefik.http.middlewares.rewrite-foo.plugin.rewrite.rewrites[1].regex: href="/
traefik.http.middlewares.rewrite-foo.plugin.rewrite.rewrites[1].replacement: href="/influxdb/
traefik.http.middlewares.rewrite-foo.plugin.rewrite.rewrites[2].regex: data-basepath="
traefik.http.middlewares.rewrite-foo.plugin.rewrite.rewrites[2].replacement: data-basepath="/influxdb/
traefik.http.middlewares.rewrite-foo.plugin.rewrite.rewrites[3].regex: n.p="/"
traefik.http.middlewares.rewrite-foo.plugin.rewrite.rewrites[3].replacement: n.p="/influxdb/"
traefik.http.middlewares.rewrite-foo.plugin.rewrite.rewrites[4].regex: \)}/health`
traefik.http.middlewares.rewrite-foo.plugin.rewrite.rewrites[4].replacement: )}/influxdb/health`
traefik.http.routers.influxdb.entrypoints: websecure
traefik.http.routers.influxdb.middlewares: rewrite-foo, influxdb_strip
traefik.http.routers.influxdb.rule: PathPrefix(`/influxdb`) || PathPrefix(`/api`)
traefik.http.routers.influxdb.tls: "true"
traefik.http.services.influxdb.loadbalancer.server.port: "8086"
networks:
- default
volumes:
- influxdb.config:/etc/influxdb2
- influxdb.data:/var/lib/influxdb2
traefik:
image: traefik:v2.9.6
ports:
- 5443:443
environment:
TRAEFIK_API_INSECURE: "false"
TRAEFIK_ENTRYPOINTS_WEBSECURE_ADDRESS: :443
TRAEFIK_EXPERIMENTAL_LOCALPLUGINS_REWRITE_MODULENAME: github.com/traefik/plugin-rewritebody
TRAEFIK_LOG_LEVEL: DEBUG
TRAEFIK_PING: "true"
TRAEFIK_PROVIDERS_DOCKER: "true"
TRAEFIK_PROVIDERS_DOCKER_EXPOSEDBYDEFAULT: "false"
healthcheck:
test:
- CMD-SHELL
- traefik healthcheck --ping
timeout: 5s
interval: 10s
retries: 5
start_period: 5s
labels:
traefik.enable: "true"
traefik.http.middlewares.traefik-auth.basicauth.users: admin:$$apr1$$8EVjn/nj$$GiLUZqcbueTFeD23SuB6x0
traefik.http.middlewares.traefik-strip.stripprefix.prefixes: /traefik
traefik.http.routers.traefik_https.entrypoints: websecure
traefik.http.routers.traefik_https.middlewares: traefik-auth,traefik-strip
traefik.http.routers.traefik_https.rule: Host(`example.localhost`) && (PathPrefix(`/traefik`) || HeadersRegexp(`Referer`, `.*/traefik/.*`))
traefik.http.routers.traefik_https.service: api@internal
traefik.http.routers.traefik_https.tls: "true"
traefik.http.services.traefik.loadbalancer.server.port: "443"
networks:
- default
volumes:
# - /var/run/docker.sock:/var/run/docker.sock # default docker context
- /run/user/1000/docker.sock:/var/run/docker.sock # rootless docker context
- ./traefik/plugins-local:/plugins-local
volumes:
influxdb.config:
name: influxdb-1-config
influxdb.data:
name: influxdb-1-data In the browser, influxdb can be reached over https://example.localhost:5443/influxdb The https://example.localhost:5443/influxdb/api/v2 or https://example.localhost:5443/api/v2 curl --insecure --location --request GET 'https://example.localhost:5443/influxdb/api/v2' \
--header 'Authorization: Token rEOYqouq5Vl4atAb4bGDox3vqNX_X0Tn2yHJV7jRqPlRz1lK0XxAiOLZADyulrdTCJ8nkmBNF_VjkmDAwLkODg==' \
--data-raw '' {
"authorizations": "/api/v2/authorizations",
"backup": "/api/v2/backup",
"buckets": "/api/v2/buckets",
"checks": "/api/v2/checks",
"dashboards": "/api/v2/dashboards",
"delete": "/api/v2/delete",
"external": {
"statusFeed": "https://www.influxdata.com/feed/json"
},
"flags": "/api/v2/flags",
"labels": "/api/v2/labels",
"me": "/api/v2/me",
"notificationEndpoints": "/api/v2/notificationEndpoints",
"notificationRules": "/api/v2/notificationRules",
"orgs": "/api/v2/orgs",
"plugins": "/api/v2/telegraf/plugins",
"query": {
"analyze": "/api/v2/query/analyze",
"ast": "/api/v2/query/ast",
"self": "/api/v2/query",
"suggestions": "/api/v2/query/suggestions"
},
"restore": "/api/v2/restore",
"scrapers": "/api/v2/scrapers",
"setup": "/api/v2/setup",
"signin": "/api/v2/signin",
"signout": "/api/v2/signout",
"sources": "/api/v2/sources",
"swagger": "/api/v2/swagger.json",
"system": {
"debug": "/debug/pprof",
"health": "/health",
"metrics": "/metrics"
},
"tasks": "/api/v2/tasks",
"telegrafs": "/api/v2/telegrafs",
"users": "/api/v2/users",
"variables": "/api/v2/variables",
"write": "/api/v2/write"
} The drawback of this solution is that no other docker service can be exposed over the traefik.http.routers.influxdb.rule: PathPrefix(`/influxdb`) || PathPrefix(`/api`) Maybe someone can help figure out how to run the influxdb api in a subpath location. |
As an alternative to the solution provided by @arun-prakash-fokus (thank you a lot!), here are the needed steps to reproduce the same approach in k8s environment using Traefik (v2.9.6), plugin-rewritebody middleware and StripPrefix middleware.
or using IngressRoute k8s CRD:
And now you will be able to access InfluxDB UI through https://myhost.com/influxdb and InfluxDB API through https://myhost.com/influxdb/api/v2 or https://myhost.com/api/v2. Note that you might have to create a PVC for plugins storage in your Traefik instance and mount it as a volume, and also maybe to re-apply your InfluxDB instance to be reachable from your ingress/ingressroute correctly. |
Thanks @robertohdzrz! This works great.
|
@arun-prakash-fokus thank you for your example config, that helped me a lot! I'd like to add some additions to your proposed solution:
traefik.http.middlewares.rewrite-foo.plugin.rewrite.rewrites[3].regex: o.p="/"
traefik.http.middlewares.rewrite-foo.plugin.rewrite.rewrites[3].replacement: o.p="/influxdb/"
Just put the content of the |
Any news ? Seems like a basic feature to have ... |
OK, I have a stupid question - wondering if anyone can help. Does the "work around" proposed by arun-prakash-fokus with the tweak proposed by kulmann still work? As in my set up, it re-writes the html pages, but it's ignoring the javascript pages for some reason. Influx is 2.7.1 I'm using chain middleware to join stripprefix and rewrite-body (tried the traefik and the packruler version):
|
FWIW, I have managed to make this work - but not using packruler plugin.
This isn't extensively tested - but I have made sure I can login, see data, etc. FWIW, I still think it would be better if InfluxDB had this built in! |
the following worked for us, we are deploying a docker stack with influxdb included influxdb is internally available at http://influxdb:8086 externally via for example https://some.domain/influxdb working location config for nginx:
|
Reducted version of above NGINX config from @fichte :
Works for us - so far - on v2.7.1 of InfluxDB, with UI compiled to use BASE_PATH=/influxdb/ui and API_BASE_PATH=/influxdb. Thank you!!! |
@fichte |
Sorry, I didn't try that. I can take a look next week though.Sent from Outlook for Android
|
@fichte solution so far works for me. Had to force disable nginx proxy caching in my instance. |
Have you found a solution? I am struggling with the same problem - some redirect doesn't seem to work for the dashboards. I am getting a "404: Page Not Found"; it seems like the nginx configuration redirects to a path /influxdb/influxdb/orgs (which obviously doesn't exist) |
Hi all! this is a working nginx config (still testing, but looks ok)
|
I tried this configuration, and it works! |
* traefik: add needed plugins to deal with influxdb not able to work properly in path /influxdb > influxdata/influxdb#15721
* traefik: add needed plugins to deal with influxdb not able to work properly in path /influxdb > influxdata/influxdb#15721
Is there a way to do this natively in InfluxDB 2? For example, Grafana has a
|
Not currently, @regnaio - that’s why we’ve ended up with the convoluted NGINX and Traefik rules I am afraid. |
@ateska , could you please describe how you compiled InfluxDB 2 and UI with I also asked this here: https://community.influxdata.com/t/how-to-build-influxdb-2-with-custom-base-path-and-api-base-path/33890 |
Tried both the hacky nginx config and the subdomain one with no luck yet — I'll stick with the port for now. +1 for this issue, needs to be addressed, it's such a basic feature. |
Please, really just fix this! Forces us to create some nasty workarounds. |
hello, please any news if it is prioritized? |
I've managed to use the following in Apache, based on #15721 (comment) above
with var prefix='/influx/';
process = {'env' : {'STATIC_PREFIX':prefix,'API_PREFIX':prefix, 'BASE_PATH': prefix, 'API_BASE_PATH':prefix}}; |
thank @alv000h , but dashboard still not work it out 404 |
I use fallback for 404, but not work
|
After lots of sleuthing through the internet... My understanding was that setting:
should have been enough, but it wasn't. I had to disable zstd also with
|
Trying to serve influxdb v2.0alpha through nginx proxy because I need to run multiple websites on the same host while admins only allow one port to be open 443.
https://dnsname/influxdb2
influxdb http page is referencing the root url path to load the site
.js
also noticed<base href="/">
is the url root.is their some header that I should be passing upstream to influxdb so it knows to use a different basepath? or could an option be added to influxd so the base path can be custom?
Thanks!
The text was updated successfully, but these errors were encountered: