This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

代理故障排除

编辑页面

了解如何使用一组推荐工具排查代理问题。


macOS 代理配置(Sierra)

概述

要在你的公司 Wi‑Fi 网络下,在本地 iOS 模拟器中运行此功能,需要一个本地代理管理器。你可以使用诸如 Charles 之类的本地代理应用。

打开 macOS 网络偏好设置

  1. 为你的 Mac 打开 系统偏好设置(Apple 菜单 > 系统偏好设置)。
  2. 进入 网络。
  3. 确保你的 位置 设置为你的代理网络,而不是“自动”。
  4. 左侧选中 Wi-Fi 和/或以太网连接后,点击窗口右下角的 高级...

配置代理地址

  1. 如果已设置,禁用/取消勾选“自动代理配置”。
  2. 勾选“网页代理 (HTTP)”,并将“网页代理服务器”设置为 127.0.0.1 : 8888
  3. 勾选“安全网页代理 (HTTPS)”,并将“安全网页代理服务器”设置为 127.0.0.1 : 8888

配置 Charles

  1. 打开 Charles

  2. 如果它询问你,不要允许它管理你的 macOS 网络配置,前面的步骤已经完成了这件事。(如果你更改了 Charles 端口,请将前面的步骤更新为正确的端口,而不是默认的 8888)

  3. 在 Charles 的菜单中进入 Proxy > External Proxy Settings,勾选 Use external proxy servers

  4. 勾选 Web Proxy (HTTP),并输入 your-corporate-proxy-uri:port-number

  5. 勾选 Proxy server requires a password

  6. Domain: YOUR DOMAIN, Username: YOUR USERNAME Password: YOUR PASSWORD

  7. Secure Web Proxy (HTTPS) 也同样设置。_请确保填写相同的代理、用户名和密码地址_字段。

  8. Bypass external proxies for the following hosts: 的文本区域中输入:

    localhost *.local

    你可能还需要包含你的邮件服务器或其他公司网络地址。

  9. 勾选“Always bypass external proxies for localhost”

iOS 模拟器配置

如果你已经有一个正在使用但无法正常工作的 iOS 模拟器自定义配置,请从菜单中选择“Simulator > Reset Content and Settings”。

如果模拟器仍然打开,请退出它。

现在,在 Charles 的“Help”菜单中选择 > Install Charles Root Certificate,然后再为 iOS Simulators 执行一次 Install Charles Root Certificate

命令行应用的代理配置

npm、git、Brew、Curl,以及任何其他命令行应用也都需要代理访问。

对于 npm

打开 ~/.npmrc 并设置:

.npmrc
http_proxy=http://localhost:8888 https_proxy=http://localhost:8888

对于 git

打开 ~/.gitconfig 并设置

.gitconfig
[http] proxy = http://localhost:8888 [https] proxy = http://localhost:8888

命令行应用

根据你的 shell 和配置,打开 ~/.bashrc~/.bash_profile~/.zshrc,或者你设置 shell 变量的其他位置,并设置:

export HTTP_PROXY="http://localhost:8888" export http_proxy="http://localhost:8888" export ALL_PROXY="http://localhost:8888" export all_proxy="http://localhost:8888" export HTTPS_PROXY="http://localhost:8888" export https_proxy="http://localhost:8888"