Solving Proxy Hell: Why I Built 'Redir' – A Surgical Environment Wrapper
The Problem: When ’no_proxy’ is Ignored
In a modern corporate environment, working behind a proxy is often a necessity. To access internal resources while still allowing VS Code to download updates, plugins, and connect to LLM providers, I rely heavily on environment variables like https_proxy and no_proxy.
However, I ran into a frustrating roadblock: A specific VS Code plugin I needed for my daily work consistently ignored the no_proxy variable but strictly enforced https_proxy. This caused internal connections to fail because the plugin tried to route them through the corporate proxy, which couldn’t see our internal network.
Since I couldn’t fix the plugin’s source code directly, I needed a way to “lie” to the plugin about its environment—surgically removing or overriding variables only for that specific process.
The Solution: Redir
Redir is a lightweight, high-performance environment filter wrapper written in C++20. It acts as a transparent proxy for any executable, allowing you to modify the environment (Add/Update/Remove) before the target application even starts.
How it works
- Rename your target executable (e.g.,
tool.exetotool_org.exe). - Replace the original file with the
redirbinary (renamed totool.exe). - Create a
tool_conf.envconfiguration file to define your environment rules.
Detailed Application & Configuration
The beauty of Redir lies in its surgical precision. You define exactly what should happen in your *_conf.env file.
Configuration Example (tool_conf.env)
# Remove problematic proxy settings for this tool
- https_proxy
- http_proxy
# Or force specific settings
+ https_proxy = http://internal-proxy.corp:8080
+ no_proxy = .internal.company.com,localhost
Activation & Debugging
To keep the tool lightweight and prevent accidental interception, Redir only activates when a specific flag is set. For troubleshooting, you can use the REDIR_DEBUG variable to trigger various diagnostic reports.
| Variable | Value | Description |
|---|---|---|
REDIR_ENABLE_REDIR |
1 |
Required. Activates the environment filtering. |
REDIR_DEBUG |
FLAG,FLAG |
Debug. Activates Diagnostic-Functions (PRE_ENV, POST_ENV, DUMP_IO, DUMP_SIGNALS). |
Platform-Specific Examples
Windows (PowerShell)
If you want to wrap a tool like vscode-helper.exe:
- Rename
vscode-helper.exe->vscode-helper_org.exe. - Copy
redir.exetovscode-helper.exe. - Set the activation flag and run your tool:
# Activate Redir and enable multi-mode debugging
$env:REDIR_ENABLE_REDIR = "1"
$env:REDIR_DEBUG = "PRE_ENV,DUMP_IO,DUMP_SIGNALS"
# Launch your wrapped tool
.\vscode-helper.exe --some-args
# Check the results in the generated dump files:
Get-ChildItem "vscode-helper_*_*.txt"
Get-ChildItem "vscode-helper_*_*.bin"
Linux (Bash)
On Linux, the setup is just as simple. Let’s assume a tool called cli-worker:
- Rename
cli-worker->cli-worker_org. - Copy
redirtocli-worker. - Run it with the required flags:
# Run with environment variables set inline
REDIR_ENABLE_REDIR=1 REDIR_DEBUG="PRE_ENV,DUMP_IO" ./cli-worker --some-args
# Verify the environment was applied:
ls cli-worker_*_pre_env.txt
ls cli-worker_*_stdin.bin
Why Use Redir?
- Surgical Precision: Only modify the variables you want.
- Transparent Execution: Full pass-through for arguments, stdin, stdout, and exit codes.
- Zero Overhead: Native C++ with no external dependencies.
- No Global Changes: Fix the environment for one specific tool without breaking the rest of your system.
Get the Source
Redir is open-source and available on GitHub. Whether you are fighting corporate proxies or just need to sandbox your environment variables, feel free to check it out!