'Is it possible to set the system proxy from golang app in macOS or Linux distributes?
I'm creating golang app with a proxy server as a pet project, and I want to have the possibility to set himself as a system proxy. Is it possible? And how?
Solution 1:[1]
Proxies are often configured through the HTTP_PROXY, HTTPS_PROXY and NO_PROXY environment variables. In Unix-style operating systems, these variables are inherited from the parent process to its child processes.
This being said:
- your program can modify its own environment and start other processes as child processes (passing in the
_PROXYvariables). - your program may modify the shell startup scripts (like
.bashrc,.cshrc), and a newly started shell will pick the values up and pass them to newly started processes.
But I am not aware that modifying the environment of other (active) processes is possible.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | chris_f |
