Proxies SupportΒΆ

OWSLib can be configured to work with proxy servers using environment variables. These can either be set in a Python script (only affecting HTTP calls within that script), as in the example below:

import os
from owslib.wms import WebMapService

os.environ['HTTP_PROXY'] = 'http://10.10.1.10:3128'
os.environ['HTTPS_PROXY'] = 'http://10.10.1.10:1080'
wms = WebMapService('https://gibs.earthdata.nasa.gov/wms/epsg4326/best/wms.cgi?', version='1.3.0')

Or through the operating system environment variables (Linux):

$ export HTTP_PROXY="http://10.10.1.10:3128"
$ export HTTPS_PROXY="http://10.10.1.10:1080"
$ export ALL_PROXY="socks5://10.10.1.10:3434"

$ python
>>> from owslib.wms import WebMapService
>>> wms = WebMapService('https://gibs.earthdata.nasa.gov/wms/epsg4326/best/wms.cgi?', version='1.3.0')

Windows (PowerShell):

$env:HTTP_PROXY = "http://10.10.1.10:3128"
$env:HTTPS_PROXY = "http://10.10.1.10:1080"
$env:ALL_PROXY = "socks5://10.10.1.10:3434"

To use HTTP Basic Auth with your proxy, use the http://user:password@host/ syntax. For example:

os.environ['HTTP_PROXY'] = 'http://username:password@10.10.1.10:3128'

For more details, refer to the Requests library documentation, which OWSLib uses for all HTTP requests.