返回文章列表文章索引阅读全文
STARBLOG / 阅读手记
FAQ & Tips

Are pip and git too slow? A tutorial for configuring Linux terminal proxy

Foreword Development nowadays heavily relies on the internet, but unfortunately, many tools are from abroad, and the access speed is too slow domestically. Therefore, configuring terminal proxies becomes essential. Introduction to ProxyChains ProxyChains is a command-line preloader that hooks into sockets in dynamically linked programs and redirects them through one or more SOCKS/HTTP proxies. GitHub address: https://github.com/rofl0r/proxychains-ng Supports MacOS and Linux.

曦远 (DealiAxy)约 9 分钟
目录10 个章节

Preface

Development nowadays is heavily dependent on the internet, but unfortunately, many tools are developed abroad, and the access speed from within China is too slow. Therefore, configuring a terminal proxy (终端代理) is quite necessary.

ProxyChains Introduction

ProxyChains is a command-line preloader that hooks into sockets in dynamically linked programs and redirects them through one or more SOCKS/HTTP proxies.

GitHub address https://github.com/rofl0r/proxychains-ng

On macOS and Linux systems, after setting up a Shadowsocks proxy, the PAC (Proxy Auto-Configuration) list can identify the domain names to be proxied. However, this requires the proxy application to support SOCKS5. If it doesn't support SOCKS5, there's no way to proxy it through Shadowsocks. Our Shell console environment does not support SOCKS proxy; it only supports HTTP proxy. If we don't set the http_proxy environment variable in the terminal, our Shell console will not be able to use the Shadowsocks proxy.

Setting http_proxy in Terminal

If you don't mind the extra steps, you can convert a SOCK proxy into an HTTP proxy by setting http_proxy in the terminal. This way, your Shell environment can indirectly use the Shadowsocks proxy as well.

export http_proxy='http://localhost:8888'
export https_proxy='http://localhost:8888'

To disable the proxy:

unset http_proxy
unset https_proxy

If you're interested, you can also add these commands to your .bashrc or .zshrc file to make it more convenient to enable the proxy globally for your Shell console.

Installing Proxychains

Open the terminal and enter the following commands.

git clone https://github.com/rofl0r/proxychains-ng.git
cd proxychains-ng
./configure
make && make install

Configuration Parameters

Modify the configuration in /usr/local/etc/proxychains.conf.

Note: Linux systems do not generate a conf file by default. You need to copy the configuration from ./src/proxychains.conf in the cloned repository to the target directory, or create it manually—both approaches are equivalent.
If the proxychain4 command does not manually specify the configuration file path, it will automatically search for it.

[ProxyList]

Add Proxy Here ...

Meanwhile

defaults set to "tor"

socks4 127.0.0.1 9050

socks5 127.0.0.1 1080 # Set your own proxy address and port here

Generally, it's 1080

## Testing

After `proxychains4` is configured, we can use it in the terminal by adding the command to proxy in the terminal. But does it really proxy everything??? The answer is that it doesn't work on MacOS, while Linux users are already fine.

proxychains4 curl -L tool.lu/ip


The result is shown below:
![](8869373-50285907393321ad.webp)
## Chat With Me

- Live Coding Stream: [https://live.bilibili.com/11883038](https://live.bilibili.com/11883038)
- WeChat Official Account: DealiAxy
- Zhihu: [https://www.zhihu.com/people/dealiaxy](https://www.zhihu.com/people/dealiaxy)
- Blog: [https://blog.deali.cn](https://blog.deali.cn)
- Jianshu: [https://www.jianshu.com/u/965b95853b9f](https://www.jianshu.com/u/965b95853b9f)
Are pip and git too slow? A tutorial for configuring Linux terminal proxy · StarBlog