macOS使用polipo

May 24, 2019

macOS 先通过 Homebrew 安装 Polipo

1
brew install polipo

在用户根目录创建或修改配置文件 ~/.polipo。有两个参数需要修改:

  • proxyPortpolipo 提供服务的端口,默认为8123;
  • socksParentProxy:本地 Socks5 地址,具体看 ShadowSocks 配置,一般为 “127.0.0.1:1080”
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
proxyAddress = "0.0.0.0"
proxyPort = 8123
allowedClients = 127.0.0.1, 10.0.1.0/24
allowedPorts = 1-65535
tunnelAllowedPorts = 1-65535
proxyName = "localhost"
cacheIsShared = false
socksParentProxy = "127.0.0.1:1080"
socksProxyType = socks5
# chunkHighMark = 33554432
# diskCacheRoot = ""
# localDocumentRoot = ""
disableLocalInterface = true
disableConfiguration = true
dnsUseGethostbyname = yes
disableVia = true
censoredHeaders = from,accept-language,x-pad,link
censorReferer = maybe
# maxConnectionAge = 5m
# maxConnectionRequests = 120
# serverMaxSlots = 8
# serverSlots = 2

启动 polipo

1
2
3
brew services start polipo
brew services restart polipo # 重启
brew services stop polipo    # 关闭

如果需要引导全部终端流量,可以把配置写到bash:

1
2
export http_proxy="http://127.0.0.1:8123"
export https_proxy="http://127.0.0.1:8123"

如果只针对某个命令走 polipo,执行命令时指定proxy:

1
2
http_proxy="http://127.0.0.1:8123" curl ip.gs
https_proxy="http://127.0.0.1:8123" curl ip.gs

curl 检查ip

1
2
3
4
5
6
7
8
9
10
11
12
13
> http_proxy="http://127.0.0.1:8123" curl ip.gs

Current IP / 当前 IP: 194.156.***.***
ISP / 运营商:  thinkhuge.net
City / 城市: Tokyo Tokyo
Country / 国家: Japan
IP.GS is now IP.SB, please visit https://ip.sb/ for more information. / IP.GS 已更改为 IP.SB ,请访问 https://ip.sb/ 获取更详细 IP 信息!
Please join Telegram group https://t.me/sbfans if you have any issues. / 如有问题,请加入 Telegram 群 https://t.me/sbfans

  /\_/\
=( °w° )=
  )   (  //
 (__ __)//

https 导流可以直接使用 http_proxy

1
2
3
4
5
6
7
8
> https_proxy="http://127.0.0.1:8123" curl https://google.com

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/">here</A>.
</BODY></HTML>