Proxy

This document describes how proxy functionality works in DotNetBrowser, namely how to configure proxy settings and handle proxy authentication requests.

DotNetBrowser uses system proxy settings by default.

System proxy

DotNetBrowser uses the same settings as Microsoft Internet Explorer.

Configurations

If you do not want to use the system proxy settings, you can configure each IEngine with its own proxy settings using Proxy:

IProxy proxy = engine.Proxy;

If you want to tell the library to use the system proxy settings again, call:

engine.Proxy.Settings = new SystemProxySettings();

Proxy settings are stored in the User Data directory. If you configure Engine to use specific User Data directory, then the proxy settings will be saved and restored the next time you create it.

Direct

The connection does not use proxy server at all in this configuration,:

engine.Proxy.Settings = new DirectProxySettings();

Auto detect

Proxy settings are automatically detected in this configuration:

engine.Proxy.Settings = new AutoDetectProxySettings();

Custom proxy settings

You can provide custom proxy settings for HTTP, HTTPS, and FTP protocols:

string proxyRules = "http=foo:80;https=foo:80;ftp=foo:80;socks=foo:80";
string exceptions = "<local>";  // bypass proxy server for local web pages
engine.Proxy.Settings = new CustomProxySettings(proxyRules, exceptions);

Examples of the proxy rules:

  • http=foopy:80;ftp=foopy2 means HTTP proxy foopy:80 for http:// URLs and HTTP proxy foopy2:80 for ftp:// URLs;
  • foopy:80 means HTTP proxy foopy:80 for all URLs;
  • socks4://foopy means SOCKS v4 proxy foopy:1080 for all URLs.

The format of the exceptions can be as follows:

  • [ URL_SCHEME "://" ] HOSTNAME_PATTERN [ ":" <port> ]

    Examples:

      foobar.com
      *foobar.com
      *.foobar.com
      *foobar.com:99
      https://x.*.y.com:99
    
  • "." HOSTNAME_SUFFIX_PATTERN [ ":" PORT ]

    Examples:

      .google.com
      .com
      http://.google.com
    
  • [ SCHEME "://" ] IP_LITERAL [ ":" PORT ]

    Examples:

      127.0.1
      [0:0::1]
      [::1]
      http://[::1]:99
    
  • IP_LITERAL "/" PREFIX_LENGHT_IN_BITS.

    Examples:

      192.168.1.1/16
      fefe:13::abc/33
    
  • "<local>". Match local addresses. <local> means that the host matches 127.0.0.1, ::1, and localhost.

If you need to provide several exception rules, you can separate them by comma, for example: *foobar.com,.google.com,<local>.

PAC

Proxy settings are received from the proxy auto-config (PAC) file. You must provide a valid URL to the required PAC file:

engine.Proxy.Settings = new PacProxySettings("<pac-file-url>");

PAC file URL must be a valid http:// address. You cannot provide a path to a *.pac file stored on a local file system. The name of the PAC file must have the pac extension, for example, http://my-site.com/proxy.pac. The pac file must be served with the application/x-ns-proxy-autoconfig mime type on a web server .

Refer to the PAC Script Error section for details.

Authentication

DotNetBrowser supports proxy authentication. Refer to the Authentication section for details.

Multiple Proxies

To use multiple proxy servers in the same .NET application, create a separate IEngine instance for each proxy. All IBrowser instances bound to the same IEngine will share the proxy settings.

Go Top