如何为 apachebench(ab) 添加 http 代理

How to add http proxy for apachebench(ab)

我想抓取 ab 发送或接收的 http 数据包。

所以我在shell命令中添加了一个http_proxy

$ export http_proxy=127.0.0.1:8888

然后我执行ab命令:

$ ab -c 1 -n 1 http://localhost/

最后,我的代理(127.0.0.1:8888)无法从 ab 获取 http 数据包。

有没有办法让ab通过http_proxy访问http?

这是我的环境:Mac OSX 10.10.3

如果您阅读了 ab 的帮助 ab -h,您会发现它支持代理选项 -X:

-X proxy:port   Proxyserver and port number to use

此选项等同于 curl-x:

-x, --proxy [PROTOCOL://]HOST[:PORT]  Use proxy on given port

它导致这个命令:

ab -c 1 -n 1 -X 127.0.0.1:8888 http://localhost/