Use the proxy from your apps
socks_port) and an HTTP proxy listener (http_port), both on 127.0.0.1 and routed the same way. Which one a tool uses depends on what it can speak. The examples assume SOCKS5 on port 1080 and the HTTP proxy on port 8081.On this page
All flextunnel guides
The one rule: let the server resolve names
A routed name is resolved and connected on the server's network, and usually does not resolve on the client at all. The name must be on the destination's routed_domains and the server's (see Routing). The examples on this page assume:
socks_port = 1080
http_port = 8081
auth_key_file = "~/.config/flextunnel/client.key"
[[destinations]]
name = "office"
server_node_id = "SERVER_ENDPOINT_ID"
routed_domains = ["*.corp.example"]So your tool must send the hostname to the proxy, not an IP it resolved itself. The HTTP proxy always gets the hostname. With SOCKS5, use remote DNS: in curl that is socks5h://, not socks5://.
Which listener to use
| Your tool… | Use |
|---|---|
speaks SOCKS5 with remote DNS: browsers, and curl and apt with socks5h:// | SOCKS5 127.0.0.1:1080 |
only speaks an HTTP proxy: wget, Docker pulls | HTTP proxy 127.0.0.1:8081 |
speaks SOCKS5 but only with client-side DNS: the JVM's socksProxyHost | HTTP proxy, if the tool has an HTTP proxy setting, since client DNS cannot resolve routed names |
| needs raw TCP and has no proxy support: databases, RDP, native JDBC | a built-in port forward |
Neither listener is on by default. Set them in the config, or pass both flags:
flextunnel client start -c client.toml --socks-port 1080 --http-port 8081curl
# A routed target: DNS and the connection happen on the server (note socks5h)
curl -x socks5h://127.0.0.1:1080 https://wiki.corp.example/
# The server machine itself (port 8000 on its loopback), no server config needed
curl -sS -x socks5h://127.0.0.1:1080 http://office.localhost.flextunnel.internal:8000/
# This client's status
curl -sS -x socks5h://127.0.0.1:1080 http://flextunnel.internal/status.txt
# The same through the HTTP proxy
curl -sS -x http://127.0.0.1:8081 http://flextunnel.internal/status.json
# Or for a whole shell session
export ALL_PROXY=socks5h://127.0.0.1:1080flextunnel.internal is answered by the client itself; see Status pages.
git
HTTPS remotes honor ALL_PROXY or http.proxy:
ALL_PROXY=socks5h://127.0.0.1:1080 git clone https://git.corp.example/repo.git
# or permanently, for that host
git config --global http.https://git.corp.example/.proxy socks5h://127.0.0.1:1080ssh remotes ignore ALL_PROXY; route them through client nc, or permanently with the ssh config below:
GIT_SSH_COMMAND='ssh -o "ProxyCommand=flextunnel client nc %h %p"' \
git clone ssh://git.corp.example/repo.gitkubectl
Set proxy-url on the cluster in your kubeconfig. The server: host must be routed on the destination and allowed by the server:
clusters:
- cluster:
server: https://k8s.corp.example:6443
proxy-url: socks5://127.0.0.1:1080 # flextunnel receives and resolves the hostname
certificate-authority-data: LS0tLS1C… # shortened
name: internalkubeconfig accepts socks5://, not socks5h://, and sends the hostname to the proxy either way. proxy-url: http://127.0.0.1:8081 works too, and is the fallback if exec, attach or port forwarding fail over SOCKS5, as exec does with kubectl older than 1.24. For an API server on the flextunnel server itself, use https://office.localhost.flextunnel.internal:6443 with a tls-server-name that matches the API server's certificate.
Browsers
Point the browser's SOCKS proxy at 127.0.0.1:1080 with remote DNS:
- Firefox: in its network settings, set a manual SOCKS v5 proxy of
127.0.0.1:1080and turn on proxying DNS through SOCKS v5 (network.proxy.socks_remote_dns = true). - Chrome / Chromium: set a SOCKS5 proxy of
127.0.0.1:1080; it always sends the hostname.
If Firefox's DNS over HTTPS is on, exempt your internal suffixes from it, or routed names fail.
FoxyProxy: only some sites
The FoxyProxy extension sends only the domains you list through flextunnel. Add a proxy entry with Type SOCKS5, Hostname / Port 127.0.0.1 / 1080, and Proxy DNS on, then one Include pattern per routed name:
| Include | Type | Pattern |
|---|---|---|
| Include | Wildcard | *.corp.example |
| Include | Wildcard | *.flextunnel.internal |
| Include | Wildcard | flextunnel.internal |
Finally, click the FoxyProxy toolbar icon and choose Proxy by Patterns; until then the patterns are not used.
Phones
On Android, the flextunnel app runs the SOCKS5 proxy for other apps; its guide covers Firefox with FoxyProxy, Chrome and other apps. On iOS, the flextunnel app browses through its own in-app browser (routing) and offers other apps localhost port forwards rather than a SOCKS5 proxy.
Tools that need the HTTP proxy
For tools with no SOCKS5 support, or whose SOCKS5 support resolves DNS locally, use the HTTP proxy. Most honor the standard variables:
export https_proxy=http://127.0.0.1:8081
export http_proxy=http://127.0.0.1:8081
wget http://wiki.corp.example/file- The JVM resolves names locally with
-DsocksProxyHost; use its HTTP proxy properties instead:-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8081 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=8081. - Docker Engine can use
HTTPS_PROXY=http://127.0.0.1:8081for image pulls when the daemon shares the flextunnel client's loopback interface. Set it in the daemon's environment and restart the daemon;~/.docker/config.jsononly affects containers and build steps. Docker Desktop has its own proxy settings. - npm / yarn:
npm config set proxy http://127.0.0.1:8081, andhttps-proxylikewise.
More tools — nc -X, proxychains-ng, package managers — are in docs/other-socks5-tools.md.
ssh through the tunnel
Use flextunnel client nc as ssh's ProxyCommand. It needs no SOCKS or HTTP port and no external netcat.
ssh -o ProxyCommand='flextunnel client nc %h %p' user@office.localhost.flextunnel.internalA destination's loopback name reaches that server machine's own sshd with no routing config. Any other host must be routed by a destination and allowed by its server. To make it permanent:
Host office nas
HostName %h.localhost.flextunnel.internal
User user
ProxyCommand flextunnel client nc %h %p
Host workstation
HostName workstation.corp.example
User user
ProxyCommand flextunnel client nc %h %pNow ssh office and git@workstation:… remotes go through the tunnel. To reach the desktop app's client, which has no client nc, use its SOCKS port with OpenBSD netcat: ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p.
ssh's own forwards
Once ssh rides the tunnel, its forwards reach further from the ssh host's network:
# Local forward: localhost:5432 → db.corp.example:5432, as seen from the workstation
ssh -o ProxyCommand='flextunnel client nc %h %p' \
-L 127.0.0.1:5432:db.corp.example:5432 user@workstation.corp.example
# Dynamic forward: a second SOCKS5 proxy on the ssh host's network
ssh -o ProxyCommand='flextunnel client nc %h %p' \
-D 127.0.0.1:1081 user@workstation.corp.exampleApps that speak no proxy
For database clients, RDP and other apps without proxy support, add a forward to client.toml:
[[forwards]]
local_port = 15432
remote_host = "db.corp.example"
remote_port = 5432Connect the app to localhost:15432. The target must be routed by a destination and allowed by its server. See Port forwards for the details.
A socat adapter
For a temporary forward without editing the config, socat can dial through the SOCKS5 listener and send the target as a name:
# the server-side wiki.corp.example:80 as a local http://localhost:8080/
socat TCP-LISTEN:8080,bind=127.0.0.1,reuseaddr,fork \
SOCKS5-CONNECT:127.0.0.1:1080:wiki.corp.example:80A web server that serves several sites by name may not match Host: localhost:8080; send the header yourself (curl -H 'Host: wiki.corp.example' http://localhost:8080/) or use the proxy directly.
Custom bind addresses
Forwards bind 127.0.0.1 and ::1. To give two remote databases the same local port, or share a service with another machine, put an external TCP adapter in front of built-in forwards:
[[forwards]]
local_port = 15432
remote_host = "db-a.corp.example"
remote_port = 5432
[[forwards]]
local_port = 25432
remote_host = "db-b.corp.example"
remote_port = 5432Linux and macOS
On Linux, further 127.x.y.z addresses can be bound directly. On macOS, add them to lo0 first (they do not survive a reboot):
sudo ifconfig lo0 alias 127.0.0.2 255.255.255.255
sudo ifconfig lo0 alias 127.0.0.3 255.255.255.255Then run one adapter per service:
socat TCP-LISTEN:5432,bind=127.0.0.2,reuseaddr,fork TCP:127.0.0.1:15432
socat TCP-LISTEN:5432,bind=127.0.0.3,reuseaddr,fork TCP:127.0.0.1:25432Apps can now use 127.0.0.2:5432 and 127.0.0.3:5432.
Windows
netsh interface portproxy can expose a forward on another address while the IP Helper service (iphlpsvc) runs. In an elevated Command Prompt (replace 192.168.1.10):
netsh interface portproxy add v4tov4 ^
listenaddress=192.168.1.10 listenport=15432 ^
connectaddress=127.0.0.1 connectport=15432
netsh interface portproxy show allRemote access also needs a Windows Firewall rule. Remove the rule when you are done:
netsh interface portproxy delete v4tov4 listenaddress=192.168.1.10 listenport=15432Binding a LAN address exposes the tunnel to anyone who can reach it: the adapter adds no authentication.