microsoft / microsoft/WSL

Feature request: Persist proxy configuration (including PAC URL) to a file instead of session-only environment variables

Open
#14,152 3 comments 5 reactions 0 assignees View on GitHub
feature
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

**Is your feature request related to a problem? Please describe.**

WSL is able to detect changes in proxy configuration on the Windows side, but the only action currently communicated to the user is that WSL needs to be restarted.

At present, proxy information is injected into WSL only as environment variables scoped to the current session. This means that when proxy settings change (for example, due to network changes, VPN connections, or WPAD updates), existing WSL sessions cannot reflect those changes dynamically. Users are required to manually restart WSL, which disrupts running workloads and long-lived sessions.

Although WSL internally knows that proxy information has changed, that information is not exposed in a persistent or inspectable way that system services can react to.

**Describe the solution you'd like**

Instead of providing proxy configuration only via session-scoped environment variables, I would like WSL to persist proxy-related information to a file inside the WSL filesystem.

Similar to how `resolv.conf` is generated and placed at `/mnt/wsl/resolv.conf`, proxy configuration could be written to a well-defined file location (for example under `/mnt/wsl/`). Ideally, this file would use an `/etc/environment` compatible `key=value` format.

The proxy-related variables written to this file would include, but are not limited to:

- HTTP_PROXY / http_proxy
- HTTPS_PROXY / https_proxy
- FTP_PROXY / ftp_proxy
- ALL_PROXY / all_proxy
- NO_PROXY / no_proxy

Providing both uppercase and lowercase variants would help maintain compatibility with existing Linux applications and tooling.

In addition, WSL currently provides the `WSL_PAC_URL` environment variable, which contains the Proxy Auto-Configuration (PAC) URL automatically resolved via [WPAD](https://en.wikipedia.org/wiki/Web_Proxy_Auto-Discovery_Protocol) on Windows. This PAC URL is also session-scoped today. Persisting `WSL_PAC_URL` to the same configuration file would make PAC-based proxy configurations usable by system-level services.
A clear and concise description of any alternative solutions or features you've considered.

**Describe alternatives you've considered**

One alternative is to implement custom scripts in each WSL distribution that read Windows proxy settings and export the appropriate environment variables during shell startup (for example in `.bashrc` or `.profile`). However, this requires per-distribution setup and duplicates logic that WSL already has.

Another alternative is to restart WSL whenever proxy settings change, but this interrupts running processes and is not practical for development or server-like workloads.

**Additional context**

Persisting `WSL_PAC_URL` is particularly important for use cases where a PAC-interpreting proxy is run as a system service inside WSL.
For example, I would like to run [alpaca proxy](https://github.com/samuong/alpaca), a PAC-aware proxy, as a systemd service inside WSL. If proxy configuration (including the PAC URL) were written in an `/etc/environment` compatible file:

- A `systemd.path` unit could monitor the file for updates when Windows proxy or WPAD configuration changes.
- A corresponding `systemd.service` unit could use `EnvironmentFile=` to load the updated proxy and PAC configuration.
- This would allow the proxy service to restart or reload automatically, without requiring a full WSL restart or user intervention.

This approach aligns well with existing Linux service management patterns and would significantly improve proxy handling in corporate or managed network environments where WPAD and PAC files are commonly used.

Contributor guide

Open the contributing guide

Research direction

Start by tracing how WSL currently injects proxy variables into session environments and how it generates /mnt/wsl/resolv.conf. Define the persistent file location and format, then verify that HTTP_PROXY, HTTPS_PROXY, FTP_PROXY, ALL_PROXY, NO_PROXY, their lowercase variants, and WSL_PAC_URL are updated when Windows proxy or WPAD settings change without restarting WSL.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux
Domain
networking, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.