Netbox: Proxy support for webhooks

Created on 16 Apr 2020  路  3Comments  路  Source: netbox-community/netbox

Environment

  • Python version: 3.6.5
  • NetBox version: 2.8.0

Proposed Functionality

It would be nice to be able to set a proxy server for the webhooks in the admin panel or in configuration.py

Use Case

The majority of the companies are behind a corporate proxy and when sending wehbooks requests to slack for example it would be convenient to be able to set a proxy server.
At the moment in my case, I have to manually modify extras/webhooks_worker.py to be able to post notifications to slack.

Database Changes

None

External Dependencies

None

accepted feature

Most helpful comment

IMO it makes more sense to establish a configuration option to be used for all outbound HTTP connections, rather than defining a proxy individually per webhook.

All 3 comments

I think we can set this by add proxy field in webhook model or add to configuration.py.

configration.py might be flexible, i think.

WEBHOOK_PROXIES = {
  'http': 'http://192.168.1.10:3128',
  'https': 'http://192.168.2.10:1080',
}

Then set this as proxies attribute to session in webhook_worker.py.

Any idea?

We did the same modification to webhook_worker.py, it works like a charm !

# We need to use proxy to send webhooks
response = session.send(prepared_request, proxies={'https': 'http://proxy.example.org:8080'})
#response = session.send(prepared_request)

But it would be nice to allow also new version checks to pass through a proxy (the same in our case). We didn't find how to do it, yet.

IMO it makes more sense to establish a configuration option to be used for all outbound HTTP connections, rather than defining a proxy individually per webhook.

Was this page helpful?
0 / 5 - 0 ratings