We have a use case where our customers require all traffic from a Balena device to be routed via a proxy. We have configured a proxy server in redsocks and that seems to be routing all traffic from the application via the configured proxy. However, it is not clear if any of the VPN traffic is being routed via the proxy.
Can some one clarify if the VPN traffic also gets routed via proxy? If not, is there a way to do that?
One of our OS engineers recently replied to this request in another post, so I will reshare that answer here. Please let us know if you have any questions upon reading it!
For networks that restrict access to balena-cloud.com subdomains the solution is to route the traffic to Balena servers through a proxy. For this purpose we include Redsocks in the host OS, which is a TCP-to-proxy redirector.
Enabling Redsocks will redirect outbound TCP traffic through the specified proxy server. So not only connections to Balena servers will go through the proxy, but all outbound TCP traffic. Redirection of the traffic to Redsocks is done through a set of iptables rules defined in the balena-proxy-config service: meta-balena/balena-proxy-config at master · balena-os/meta-balena · GitHub
For configuring a proxy I would suggest doing that through the Balena Supervisor API: Interacting with the balena Supervisor - Balena Documentation
Q: Does OpenVPN traffic go through the proxy?
A: The OpenVPN client that runs in the host OS is configured to use the TCP protocol and the connection itself is encrypted with SSL. Currently it connects to cloudlink.balena-cloud.com on port 443. It is running on top of TCP (instead of UDP) and uses port 443 (which is also used for HTTPS traffic) as those are usually allowed on restrictive networks.
Since the OpenVPN client is configured to run on top of TCP under balenaOS that means that if Redsocks is enabled, the VPN traffic will also go through the proxy.