lukecyca/pyzabbix

How to use proxy

wongkunkun opened this issue · 2 comments

When I use: zapi = ZabbixAPI("http://zabbixserver.example.com")
How could I use http_proxy and https_proxy?

jooola commented

Hi,
I am not sure to understand your question, could you provide more details ?

@jooola I think he has a proxy between his client (python) and Zabbix API. @wongkunkun did you try using HTTP_PROXY env var? Or, if that's not an option and you want to set it in code, create a custom Session object, like:

from requests import Session
from pyzabbix import ZabbixAPI

session = Session()
session.proxies = {
   'http': 'http://192.168.0.1:3128',
   'https': 'http://192.168.0.1:3128',
}

zapi = ZabbixAPI("http://zabbixserver.example.com", session=session)