Proxy Configuration
Configuring Your Application Proxy Server
Every language has it's own nuances for how it works with a forward proxy server for outbound traffic. Select your language to see well-known patterns for that language.
- Go
- Python
- Node.js
- Java
Golang supports HTTP_PROXY
and HTTPS_PROXY
environment variables to configure outbound http or https
requests. For example, when the sidecar is configured as a socks forward proxy:
export HTTP_PROXY='socks5://127.0.0.1:4140'
export HTTPS_PROXY='socks5://127.0.0.1:4140'
Or alternatively as an http forward proxy:
export HTTP_PROXY='http://127.0.0.1:4140'
export HTTPS_PROXY='http://127.0.0.1:4140'
Python supports HTTP_PROXY
and HTTPS_PROXY
as well as the lowercase alternatives http_proxy
and
https_proxy
. This is true if you are using either the standard library urllib.request
module or the
popular requests
module. These two options can also support specifying proxies directly with a dictionary:
urllib.request.urlopen(
'http://example.com',
proxies={
'http': 'http://localhost:4140',
'https': 'http://localhost:4140',
},
)
Socks proxies may require additional dependencies. For example, with the requests
module:
https://requests.readthedocs.io/en/latest/user/advanced/?highlight=proxy#socks
When using Node, you need to set proxy-protocol
to http
or tcp:http
. In addition, the NodeJS app needs
to be configured with global-agent:
npm install --save global-agent
Then add global-agent to your code:
import 'global-agent/bootstrap';
Set these environment variables in the NodeJS runtime environment to configure the global-agent proxy:
export GLOBAL_AGENT_HTTP_PROXY='http://127.0.0.1:4140'
export GLOBAL_AGENT_HTTPS_PROXY='http://127.0.0.1:4140'
export GLOBAL_AGENT_NO_PROXY='*127.0.0.1:12557'
export NODE_EXTRA_CA_CERTS=${HOME}/.speedscale/certs/tls.crt
When using Java, you need to set proxy-protocol
to socks
or tcp:socks
. Java has built-in system
properties for configuring the socks proxy server, add the following -D
system property flags:
-DsocksProxyHost=127.0.0.1
-DsocksProxyPort=4140