I’m using Composer as package management in my projects. Recently, the Packagist access too slow from mainland. So I need to use proxy for Composer.

Step 1

Install Privoxy

brew install privoxy

Step 2

Update Privoxy configuration

...

listen-address 127.0.0.1:8118
forward-socks5 / 127.0.0.1 .

...

Step 3

Start the Privoxy service

brew services start privoxy

Step 4

Export HTTP_PROXY / HTTPS_PROXY

export HTTP_PROXY=http://127.0.0.1:8118
export HTTPS_PROXY=http://127.0.0.1:8118
export NO_PROXY=10.0.0.0/8,192.168.0.0/16