Skip to content

Commit 5dae6c3

Browse files
authored
feat: proxy support (#76)
Signed-off-by: Michal Fiedorowicz <[email protected]>
1 parent 4cb09b8 commit 5dae6c3

File tree

4 files changed

+880
-93
lines changed

4 files changed

+880
-93
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,48 @@ client = DiodeClient(target="grpcs://example.com", ...)
213213
client = DiodeClient(target="grpc://example.com", ...)
214214
```
215215

216+
### Proxy support
217+
218+
The SDK automatically detects and uses HTTP/HTTPS proxies configured via standard environment variables:
219+
220+
```bash
221+
# For insecure connections
222+
export HTTP_PROXY=http://proxy.example.com:8080
223+
224+
# For secure connections
225+
export HTTPS_PROXY=http://proxy.example.com:8080
226+
# Falls back to HTTP_PROXY if HTTPS_PROXY is not set
227+
228+
# Bypass proxy for specific hosts
229+
export NO_PROXY=localhost,127.0.0.1,.example.com
230+
```
231+
232+
**Important notes for proxy usage:**
233+
234+
1. **Proxy with SKIP_TLS_VERIFY**: When using HTTP(S) proxies, the SDK **always uses secure channels** because proxies require TLS for the CONNECT tunnel. Setting `DIODE_SKIP_TLS_VERIFY=true` with a proxy will log a warning and use a secure channel anyway.
235+
236+
2. **MITM proxies (like mitmproxy)**: To use an intercepting proxy, you must provide the proxy's CA certificate:
237+
```bash
238+
export HTTPS_PROXY=http://127.0.0.1:8080
239+
export DIODE_CERT_FILE=~/.mitmproxy/mitmproxy-ca-cert.pem
240+
```
241+
242+
3. **Non-intercepting proxies**: Regular forwarding proxies work without additional configuration if the target server has a valid certificate trusted by system CAs.
243+
244+
Example with proxy:
245+
```python
246+
import os
247+
248+
# Configure proxy
249+
os.environ["HTTPS_PROXY"] = "http://proxy.example.com:8080"
250+
251+
client = DiodeClient(
252+
target="grpcs://diode.example.com:443",
253+
app_name="my-app",
254+
app_version="1.0.0",
255+
)
256+
```
257+
216258
#### Using custom certificates
217259

218260
```python

0 commit comments

Comments
 (0)