Why can`t wrtite data to InfluxDB v3 through nginx upstream?
I am using the influxdb3-python library with InfluxDB v3. When I try to read data, everything works, but as soon as I try to write data to the DB, it throws an error:
(0)
Reason: SSLError
[SSL] unknown error (_ssl.c:1000)
On the server, I use a combination of nginx + influxdb, and everything is wrapped in Docker.
Nginx.conf:
stream {
ssl_certificate /etc/letsencrypt/live/example.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.ru/privkey.pem;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 4h;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_alpn h2;
upstream influxdb_steam {
server influx:8181;
}
server {
listen 8088 ssl;
proxy_pass influxdb_steam;
}
}
Python code:
import time
from influxdb_client_3 import InfluxDBClient3
if __name__ == '__main__':
try:
clien_influx3 = InfluxDBClient3(
token="my_token",
host="https://example.ru:8088",
database="myDB"
)
now = int(time.time())
data = [
{
"measurement": "mymeasure",
"tags": {
"mes": "mes-1"
},
"time": datetime.datetime.utcfromtimestamp(
now).strftime('%Y-%m-%dT%H:%M:%SZ'),
"fields": {
"value": 1.0,
}
},
]
result = clien_influx3.write(data)
except Exception as e:
print(e)
But if i try, it`s working:
curl -k --verbose -X POST "https://example.ru:8088/api/v2/write?bucket=myDB&org=" \
-H "Authorization: Token my_token" \
-H "Content-Type: text/plain; charset=utf-8" \
--data-binary "mymeasure,mes=mes-1 value=1.0 1765869879000000000"
Versions:
Nginx 1.22.0
InfluxDB 3.5.0-core
Python 3.12
influxdb3-python 0.16.0