Proxysetting

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:

1
2
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:

1
2
npm config delete proxy
npm config delete https-proxy

Linux Shell Proxy Configuration

Setting up Proxy

You can set proxy environment variables in the shell as follows:

1
2
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:

1
2
unset http_proxy
unset https_proxy

Pip Proxy Configuration

Using Proxy with Pip

1
pip --proxy http://localhost:7890 install somepackage

Replace 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.

1
git config --global http.proxy http://127.0.0.1:7890
1
git config --global http.https://github.com.proxy http://127.0.0.1:7890
1
2
3
git config --global --unset http.proxy
git config --global --unset http.https://github.com.proxy

unfinished