Use HTTP Proxy under outputs.http

Is there a way to add a proxy address when using HTTP server. I see we have an option of using proxy when the server is influxdb, just wondering if we can use proxy for HTTP server.

Currently, our setup has HTTP server deployed and without proxy the data gets uploaded successfully. When we try using a proxy with InfluxDB server, we get a 400 Bad Request.

Error:
When writing to [https://xxxxx/telegraf]: database “” creation failed: 400 Bad Request
2020-02-04T17:42:13Z E! [agent] Error writing to outputs.influxdb: could not write any address

I know one way to resolve this issue is to change the server to influx but that requires lot more changes and lot of redeployment. Can we make it work with HTTP server with proxy?

We don’t have an option for this but it would be nice to add one, could you will open a new Telegraf GitHub issue. The http output does support reading from the http_proxy and https_proxy environment variables though, so perhaps this would be enough to get up and running? On Linux you can set environment variables in /etc/defaults/telegraf.

Thanks Daniel. Adding http_proxy and https_proxy to environment variable does work and http.output picks up the proxy credentials and endpoint correctly. But, I get a forbidden error from the proxy.

2020-02-04T22:42:18Z E! [agent] Error writing to outputs.http: Post https://xxxx:8080 : Forbidden
The credentials are correct and without proxy I do have permission to upload data. Any thoughts?

Are you setting a username and password in the http_proxy environment variable? If not, it appears you need one. If you are, then perhaps they are not url encoded properly, make sure any special characters in the username and password are properly escaped.