Reputation: 2263
I receive the following error when i try to access InfluxDB admin UI or via Graphana:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://54.zzz.xx.yyy:8086/cluster_admins/authenticate?u=abc&p=dec. This can be fixed by moving the resource to the same domain or enabling CORS.
Note that I get this error only when I try to connect via Internet, when I go to the servers local network and change the public IP mentioned above to local IP, everything works.
Now I understand what is cross-domain error and CORS, I also get that I need to enable CORS as the error says in InfluxDB server, point is I don't know how to do that.
InfluxDB is on a Ubuntu server 14.something on AWS.
Upvotes: 3
Views: 2407
Reputation: 1367
Although this is already answered, I would like to share my solution for an Angular app accessing InfluxDB using docker and Apache as a reverse proxy. With this setup you can make requests to InfluxDB
from localhost:4200
via http://localhost:8080/query?[..]
.
docker-compose.yml
version: '3'
services:
apache:
image: bitnami/apache:2.4
ports:
- 8080:8080
volumes:
- ./apache/influxdb_proxy.conf:/vhosts/influxdb_proxy.conf:ro
influxdb:
image: influxdb:1.7
ports:
- 8086:8086
volumes:
- ./influxdb/data:/var/lib/influxdb
apache/influxdb_proxy.conf
ProxyPass / http://influxdb:8086/
ProxyPassReverse / http://influxdb:8086/
Header set Access-Control-Allow-Origin "http://localhost:4200"
Upvotes: 0
Reputation: 2263
Since nobody answered, I resorted to my backup option, used IIS as a proxy which internally reads from local intranet and hence avoids the cross-domain error.
You can use Apache or any other web server which has URL rewriting capabilities, in my case I used IIS.
Edit: Turns out its hard coded for now and will be changed later: https://github.com/influxdb/influxdb/issues/1244#issuecomment-68219522
Upvotes: 3