loganmarchione / docker-speedtest-influxdbv2

Runs Ookla's Speedtest CLI program in Docker, sends the results to InfluxDB
https://hub.docker.com/r/loganmarchione/docker-speedtest-influxdbv2
9 stars 9 forks source link

Allow HTTPS endpoint #4

Closed shad-lp closed 3 years ago

shad-lp commented 3 years ago

Hello @loganmarchione

I'm using InfluxDB behind a reverse proxy. I noticed that the http protocole is hardcoded into your code. Could you add an environment variable to specify the protocol ? something like INFLUXDB_SCHEME.

Thank you.

loganmarchione commented 3 years ago

I pushed 0.0.13 to DockerHub. Can you test it using HTTPS? My instance of InfluxDB is running in Docker over HTTP, not HTTPS, so I can't test.

The variable is INFLUXDB_SCHEME=https and it defaults to http but can be set to https. The log also writes the full InfluxDB URL to output.

Let me know how it goes.

shad-lp commented 3 years ago

Hello,

I pulled the new image and at the moment I can't make it work. My docker-compose file :

version: '2.1'
services:

   speedtest-idb:
      image: loganmarchione/docker-speedtest-influxdbv2
      container_name: speedtest-idb
      network_mode: bridge
      environment:
         - INFLUXDB_SCHEME=https
         - INFLUXDB_HOST=influxdb.aelnet.ovh
         - INFLUXDB_PORT=443
         - SLEEPY_TIME=3600
      env_file:
         # contains InfluxDB database credentials
         - /opt/speedtest-idb/speedtest-idb.env
      labels:
#         - "diun.enable=true"
         - "com.centurylinklabs.watchtower.enable=true"
      volumes:
         - /etc/localtime:/etc/localtime:ro
         - /etc/timezone:/etc/timezone:ro
         - config:/usr/scr/app
      restart: unless-stopped

volumes:

   config:

Logs at startup :

lawrence@srv-debian:/opt/speedtest-idb$ docker-compose -f docker-compose_speedtest-idb.yml up -d && docker-compose -f docker-compose_speedtest-idb.yml logs -f
Creating speedtest-idb ... done
Attaching to speedtest-idb
speedtest-idb    | #####
speedtest-idb    | Script starting!
speedtest-idb    | #####
speedtest-idb    | STATE: Starting at 2021-07-07T18:54:07.113729
speedtest-idb    | STATE: Sleep time between runs set to 3600 seconds
speedtest-idb    | STATE: Checking environment variables...
speedtest-idb    | STATE: Connecting to InfluxDB...
speedtest-idb    | STATE: Running database check
speedtest-idb    | ERROR: Connection fail  - Check host, port, user, pass

I'm not getting the full URL in the output as you mentionned.

EDIT : I can confirm that using port 8086 with HTTP scheme is still working in 0.0.13 I can also confirm that Telegraf manages to reach InfluxDB through a reverse proxy :

speedtest_https_1

speedtest_https_2

loganmarchione commented 3 years ago

Are you sure that's the new image? I'm not seeing the new error message with the word "scheme" in it.

https://github.com/loganmarchione/docker-speedtest-influxdbv2/blob/65556ba4b344fe30874fc6ad8dc9cf04e4944370/speedtest.py#L32

shad-lp commented 3 years ago

I juste erased latest and 0.0.13 images and recreated the container from scratch, tag if specified this time in the compose file :

version: '2.1'
services:

   speedtest-idb:
      image: loganmarchione/docker-speedtest-influxdbv2:0.0.13
      container_name: speedtest-idb
      network_mode: bridge
      environment:
         - INFLUXDB_SCHEME=https
         - INFLUXDB_HOST=influxdb.aelnet.ovh
         - INFLUXDB_PORT=443
         - SLEEPY_TIME=3600
      env_file:
         # contains InfluxDB database credentials
         - /opt/speedtest-idb/speedtest-idb.env
      labels:
#         - "diun.enable=true"
         - "com.centurylinklabs.watchtower.enable=true"
      volumes:
         - /etc/localtime:/etc/localtime:ro
         - /etc/timezone:/etc/timezone:ro
         - config:/usr/scr/app
      restart: unless-stopped

volumes:

   config:

Pulling and starting container :

docker-compose -f docker-compose_speedtest-idb.yml up -d && docker-compose -f docker-compose_speedtest-idb.yml logs -f

Still no scheme mention in the logs :

speedtest-idb    | #####
speedtest-idb    | Script starting!
speedtest-idb    | #####
speedtest-idb    | STATE: Starting at 2021-07-07T19:21:19.260415
speedtest-idb    | STATE: Sleep time between runs set to 3600 seconds
speedtest-idb    | STATE: Checking environment variables...
speedtest-idb    | STATE: Connecting to InfluxDB...
speedtest-idb    | STATE: Running database check
speedtest-idb    | ERROR: Connection fail  - Check host, port, user, pass

I should add that I'm using InfluxDB 1.8, but right now the problem seems elsewhere.

shad-lp commented 3 years ago

My bad, I had to delete the docker volume, works like a charm now. Thank you !

loganmarchione commented 3 years ago

Good to know, thanks! Can I close this?

shad-lp commented 3 years ago

Sure