Configuring Proxy Settings
In the development world, setting up a proxy is a common task, especially when working behind a corporate firewall or when you want to ensure secure and private browsing. Proxies act as intermediaries between your computer and the internet, helping in filtering requests, improving security, and managing network traffic more efficiently.
NPM
Setting up Proxy in NPM
To configure npm to use a proxy, you can use the npm config set command as follows:
npm config set proxy "http://localhost:7890"npm config set https-proxy "http://localhost:7890"Here, http://localhost:7890 is the address of your proxy server. Change it according to your proxy server’s IP address and port number.
Removing Proxy Configuration
If you need to remove the proxy configuration, for instance, when you’re not behind a proxy anymore, you can use the npm config delete command:
npm config delete proxynpm config delete https-proxyLinux Shell Proxy Configuration
Setting up Proxy
You can set proxy environment variables in the shell as follows:
export http_proxy="http://localhost:7890"export https_proxy="http://localhost:7890"Replace localhost:7890 with the actual proxy endpoint. The variable name selects the destination protocol; the URL scheme describes the proxy connection. For an HTTP CONNECT proxy, both variables normally use http://. Use https:// only for a TLS-capable proxy endpoint. For a SOCKS proxy, use a supported socks5:// or socks5h:// endpoint instead; socks5h requests proxy-side DNS resolution. Client support differs. A proxy alone does not guarantee privacy or security.
Removing Proxy Configuration
To revert the changes or to disable the use of a proxy, you can unset these environment variables:
unset http_proxyunset https_proxyPip Proxy Configuration
Using Proxy with Pip
pip --proxy http://localhost:7890 install somepackageReplace http://localhost:7890 with your proxy’s URL. Append the name of the package you wish to install instead of somepackage.
git
Git uses http.proxy (including for HTTPS remotes). The URL-scoped http.https://github.com.proxy overrides it for that host. Remove the matching scoped key as well when reverting; https.proxy is not the documented HTTP transport key.
git config --global http.proxy http://127.0.0.1:7890git config --global http.https://github.com.proxy http://127.0.0.1:7890git config --global --unset http.proxygit config --global --unset http.https://github.com.proxy