代理#
代理适用于企业网络, 地理位置测试, 抓取基础设施, 以及受控出口流量.
CLI 标志#
bash
agent-browser --proxy "http://proxy.example.com:8080" open https://example.com
agent-browser --proxy "http://user:pass@proxy.example.com:8080" open https://example.com
agent-browser --proxy "http://proxy.example.com:8080" --proxy-bypass "localhost,*.internal.com" open https://example.com| 标志 | 说明 |
|---|---|
--proxy <url> | 代理服务器 URL,可选带凭据 |
--proxy-bypass <hosts> | 应绕过代理的主机 |
环境变量#
| 变量 | 说明 |
|---|---|
AGENT_BROWSER_PROXY | agent-browser 代理 URL |
AGENT_BROWSER_PROXY_BYPASS | agent-browser 代理绕过列表 |
AGENT_BROWSER_PROXY_USERNAME | 当凭据分开提供时使用的代理用户名 |
AGENT_BROWSER_PROXY_PASSWORD | 当凭据分开提供时使用的代理密码 |
HTTP_PROXY / HTTPS_PROXY | 标准代理环境变量,作为后备使用 |
ALL_PROXY | SOCKS 或全流量代理后备 |
NO_PROXY | 标准代理绕过后备 |
AGENT_BROWSER_PROXY 的优先级高于标准代理变量。CLI 也接受嵌入在代理 URL 中的凭据,并会在把启动选项传给守护进程前先拆分它们。
SOCKS 代理#
bash
export ALL_PROXY="socks5://proxy.example.com:1080"
agent-browser open https://example.com
export ALL_PROXY="socks5://user:pass@proxy.example.com:1080"
agent-browser open https://example.com绕过本地流量#
bash
export AGENT_BROWSER_PROXY="http://proxy.example.com:8080"
export AGENT_BROWSER_PROXY_BYPASS="localhost,127.0.0.1,*.internal.com"
agent-browser open https://external.example.com
agent-browser open http://localhost:3000验证路由#
bash
agent-browser open https://httpbin.org/ip
agent-browser get text body返回结果应显示代理出口地址,而不是本机的直连网络地址。
安全提示#
- 优先使用环境变量或密钥存储保存代理凭据。
- 不要提交代理用户名、密码或会话 URL。
- HAR 导出和网络日志可能包含经过代理认证的请求。