Skip to content

Commit 8bb8e8e

Browse files
committed
Add docs on using proxies
1 parent 145e4a2 commit 8bb8e8e

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ OWSLib |release| documentation
2424
development
2525
support
2626
logging
27+
proxies
2728
license
2829
credits

docs/source/proxies.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Proxies Support
2+
===============
3+
4+
OWSLib can be configured to work with proxy servers using environment variables.
5+
These can either be set in a Python script (only affecting HTTP calls within that script), as in the example below:
6+
7+
.. code-block:: python
8+
9+
import os
10+
from owslib.wms import WebMapService
11+
12+
os.environ['HTTP_PROXY'] = 'http://10.10.1.10:3128'
13+
os.environ['HTTPS_PROXY'] = 'http://10.10.1.10:1080'
14+
wms = WebMapService('https://gibs.earthdata.nasa.gov/wms/epsg4326/best/wms.cgi?', version='1.3.0')
15+
16+
Or through the operating system environment variables (Linux):
17+
18+
.. code-block:: bash
19+
20+
$ export HTTP_PROXY="http://10.10.1.10:3128"
21+
$ export HTTPS_PROXY="http://10.10.1.10:1080"
22+
$ export ALL_PROXY="socks5://10.10.1.10:3434"
23+
24+
$ python
25+
>>> from owslib.wms import WebMapService
26+
>>> wms = WebMapService('https://gibs.earthdata.nasa.gov/wms/epsg4326/best/wms.cgi?', version='1.3.0')
27+
28+
Windows (PowerShell):
29+
30+
.. code-block:: ps1
31+
32+
$env:HTTP_PROXY = "http://10.10.1.10:3128"
33+
$env:HTTPS_PROXY = "http://10.10.1.10:1080"
34+
$env:ALL_PROXY = "socks5://10.10.1.10:3434"
35+
36+
To use HTTP Basic Auth with your proxy, use the http://user:password@host/ syntax. For example:
37+
38+
.. code-block:: python
39+
40+
os.environ['HTTP_PROXY'] = 'http://username:password@10.10.1.10:3128'
41+
42+
43+
For more details, refer to the `Requests library documentation <https://requests.readthedocs.io/en/latest/user/advanced/#proxies>`__,
44+
which OWSLib uses for all HTTP requests.

0 commit comments

Comments
 (0)