Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy support for Windows with moproxy #4013

Closed
tperale opened this issue Feb 22, 2023 · 1 comment
Closed

Proxy support for Windows with moproxy #4013

tperale opened this issue Feb 22, 2023 · 1 comment
Assignees
Milestone

Comments

@tperale
Copy link
Contributor

tperale commented Feb 22, 2023

Problem Description

I've been working for the past month on the support of proxies for the Windows version of rancher-desktop. It has been a known issue for a long time that you can't use rancher-desktop with a corporate proxy in Windows because WSL does not takes the proxy settings of the host into account. Here is a list of some issues related to proxy in Windows:

If you use rancher-desktop behind a proxy you can't:

  • Install it, because you need to pull docker container during the installation
  • Run it because you get an error from kubernetes.
  • Do a docker pull/push

There has been different proposal in Github issue discussions about how to use a proxy with rancher-desktop:

  • Setting http_proxy, https_proxy in WSLENV. This will create an error from kubernetes.
  • Using wsl-vpnkit
  • Setting the variable in rc.conf

Proposed Solution

None of the solution proposed really worked. Using WSLENV introduce the error with kubernetes and will share the proxy variable with every WSL VM. Based on discussion I had in the rancher-desktop slack I opted for a solution based on the usage of a proxy running inside WSL that could be programmatically enabled/disabled to catch the network traffic and forward it to an http proxy.

My changes to the rancher-desktop-wsl-vm and rancher-desktop code are available here:

My solution is based on a software named moproxy, a software installed on WSL as a service that handles the connections and transmissions of packets to an http proxy. The traffic from the network interface is redirected to moproxy using iptables, so any type of filtering on ports/address is supported.

flowchart  LR;
 subgraph VM["WSL VM"]
   direction LR
   apps{{"Apps"}}
   subgraph vmIptables["iptables"]
   direction LR
     rules{"Rules"}
   end
   moproxy["moproxy"]
   apps -- TCP --> rules
   rules --> moproxy
 end
 proxy((("Proxy")))
 moproxy --> proxy
Loading

I also made changes to the rancher-desktop graphical interface to make the proxy configurable from the rancher-desktop settings page or during the first run. For now my changes are only available in the WSL setting page but in the future it could probably be ported to other platforms.

settings

firstrun

Changes on the proxy configuration take effect immediately after clicking on Apply without having to restart the backend like the other change in settings.

Additional Information

Recently there has been some activity on the Github issues to port the network stack to work with gvisor-tap-vsock (see Epic: Incorporate gvisor into Rancher Desktop's networking stack). I'm waiting for the release of this experimental feature in rancher-desktop 1.8 to see how gvisor-tap-vsock can work with proxy and if my changes are still required.

flowchart  LR;
 subgraph VM["VM"]
   direction LR
   apps{{"Apps"}}
   subgraph vmIptables["iptables"]
   direction LR
     rules{"Rules"}
   end
   moproxy["moproxy"]
   vmSwitch["VM Daemon Switch"]
   apps -- TCP --> rules
   rules --> moproxy
   moproxy -- TAP --> vmSwitch
 end
 subgraph host["Host"]
   hostSwitch["Host Switch"]
 end
 vmSwitch -- VSOCK --> hostSwitch
 proxy((("Proxy")))
 hostSwitch -- CONNECT --> proxy
Loading
@gaktive
Copy link
Contributor

gaktive commented Jun 5, 2023

Work for this is being tracked in #4603 so closing this as a sorta duplicate.

@gaktive gaktive closed this as completed Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants