Configure HTTP or HTTPS proxies for the V2.0 SDK to route requests through a proxy server for access control, logging, caching, or lazy loading without modifying your application code.
Proxy types
HTTP and HTTPS proxies are supported.
|
Proxy type |
Description |
|
HTTP proxy |
Use the httpProxy parameter to configure the proxy server address and port. The format is |
|
HTTPS proxy |
Use the httpsProxy parameter to configure the proxy server address and port. The format is |
If the proxy server requires identity authentication, add the username and password to the address. Use the following format: http://<user>:<password>@<IP address>:<port>
After you configure a proxy, you can also use the noProxy parameter to specify a list of addresses that do not require a proxy. Separate multiple addresses with commas. You can use domain names and IP addresses.
Configuration method
Proxy settings in RuntimeOptions override the settings in the client Config.
-
Configure a proxy by using the RuntimeOptions object.
const { RuntimeOptions } = require('@alicloud/tea-util'); const runtime = new RuntimeOptions({ // Configure an HTTP proxy. httpProxy: "http://xx.xx.xx.xx:8089", // Configure an HTTPS proxy. httpsProxy: "https://xxx.xxx.xxx.xxx:9999", // Configure the addresses that do not require a proxy. noProxy: '127.0.0.1,localhost', });import * as $Util from '@alicloud/tea-util'; // Create a RuntimeOptions instance and set runtime parameters. const runtime = new $Util.RuntimeOptions({ // Configure an HTTP proxy. httpProxy: "http://xx.xx.xx.xx:8089", // Configure an HTTPS proxy. httpsProxy: "https://xxx.xxx.xxx.xxx:9999", // Configure the addresses that do not require a proxy. noProxy: '127.0.0.1,localhost' }); -
Configure a global proxy by using the Config object. This proxy applies to all requests from the client.
const { Config } = require('@alicloud/openapi-client'); const config = new Config({ // Configure an HTTP proxy. httpProxy: "http://xx.xx.xx.xx:8089", // Configure an HTTPS proxy. httpsProxy: "https://xxx.xxx.xxx.xxx:9999", // Configure the addresses that do not require a proxy. noProxy: '127.0.0.1,localhost', });import * as $OpenApi from '@alicloud/openapi-client'; const config = new $OpenApi.Config({ // Configure an HTTP proxy. httpProxy: "http://xx.xx.xx.xx:8089", // Configure an HTTPS proxy. httpsProxy: "https://xxx.xxx.xxx.xxx:9999", // Configure the addresses that do not require a proxy. noProxy: '127.0.0.1,localhost' });
References
For more information about proxy configuration, see HTTP proxy configuration practices.