Skip to main content

使用代理

¥Using a Proxy

代理支持内置于 Ionic CLI 中。代理设置可以通过配置文件或环境变量进行配置。

¥Proxy support is built-in to the Ionic CLI. Proxy settings can be configured via the config file or an environment variable.

要通过配置文件配置代理设置,请使用代理服务器的 URL 运行以下命令:

¥To configure proxy settings via the config file, run the following with the URL of the proxy server:

ionic config set -g proxy http://proxy.example.com:8888

要通过环境变量配置代理设置,请使用以下选项之一:

¥To configure proxy settings via an environment variable, use one of the following:

$ export HTTP_PROXY="http://proxy.example.com:8888" # also used by npm
$ export HTTPS_PROXY="https://proxy.example.com:8888" # also used by npm
$ export IONIC_HTTP_PROXY="http://proxy.example.com:8888"

其他 CLI

¥Other CLIs

你使用的每个 CLI 必须单独配置以代理网络请求。

¥Each CLI that you use must be configured separately to proxy network requests.

npm

npm config set proxy http://proxy.company.com:8888

git

git config --global http.proxy http://proxy.example.com:8888

SSL 配置

¥SSL Configuration

Ionic CLI 可以配置为对 HTTP 请求使用各种 SSL 设置。

¥The Ionic CLI can be configured to use various SSL settings for HTTP requests.

$ ionic config set -g ssl.cafile /path/to/cafile # file path to your CA root certificate
$ ionic config set -g ssl.certfile /path/to/certfile # file path to a client certificate
$ ionic config set -g ssl.keyfile /path/to/keyfile # file path to a client key file

可以将 cafilecertfilekeyfile 条目手动编辑为 ~/.ionic/config.json 中的字符串数组,以包含多个文件。

¥The cafile, certfile, and keyfile entries can be manually edited as arrays of strings in ~/.ionic/config.json to include multiple files.