ProxyConfiguration
Hierarchy
- ProxyConfiguration
- ProxyConfiguration
Index
Properties
Methods
Properties
readonlyconfiguration
externalreadonlyinheritedisManInTheMiddle
Methods
initialize
Loads proxy password if token is provided and checks access to Apify Proxy and provided proxy groups if Apify Proxy configuration is used. Also checks if country has access to Apify Proxy groups if the country code is provided.
You should use the createProxyConfiguration function to create a pre-initialized
ProxyConfigurationinstance instead of calling this manually.Parameters
optionaloptions: { checkAccess?: boolean }
optionalcheckAccess: boolean
Returns Promise<boolean>
newProxyInfo
Returns a new ProxyInfo object with a fresh proxy URL. Each call mints an independent URL; for Apify Proxy a random session id is embedded so consecutive calls resolve to different IPs.
A passed
proxyInfo(e.g. one restored with a persisted session) is returned unchanged, unless it is an Apify Proxy one. Its endpoint is specific to the host, so it is moved to the current endpoint, keeping the username and with it the proxy session.Parameters
optionalproxyInfo: ProxyInfo
Returns Promise<undefined | ProxyInfo>
newUrl
Returns a new proxy URL. For Apify Proxy, each call generates a URL with a fresh random session id, so consecutive calls return independent URLs. For custom
proxyUrls, the URLs are rotated round-robin.Returns Promise<undefined | string>
Configures connection to a proxy server with the provided options. Proxy servers are used to prevent target websites from blocking your crawlers based on IP address rate limits or blacklists. Setting proxy configuration in your crawlers automatically configures them to use the selected proxies for all connections. You can get information about the currently used proxy by inspecting the ProxyInfo property in your crawler's page function. There, you can inspect the proxy's URL and other attributes.
The proxy servers are managed by Apify Proxy. To be able to use Apify Proxy, you need an Apify account and access to the selected proxies. If you provide no configuration option, the proxies will be managed automatically using a smart algorithm.
If you want to use your own proxies, use the ProxyConfigurationOptions.proxyUrls option. Your list of proxy URLs will be rotated by the configuration if this option is provided.
Example usage: