Chapter 31. Proxy Services

ServiceBlox offers two kinds of proxy services: exact proxies and transparent proxies. An exact proxy forwards a request directed at one specific service to a different service, possibly hosted on a different machine. A transparent proxy forwards all requests directed at a certain URL prefix to a given host.

Exact Proxies.  The following example (see lb-web-samples/protobuf-proxy-auth) illustrates how to configure an authenticated exact proxy service.

block(`service_config) {

  alias_all(`lb:web:config:service),
  alias_all(`lb:web:config:service_abbr),
  alias_all(`lb:web:config:auth),
  alias_all(`lb:web:config:auth_abbr),
  alias_all(`lb:web:config:proxy),

  clauses(`{

    service_by_prefix["/time-proxy-auth"] = x,
    exact_proxy(x) {
      proxy_target[] = "http://localhost:8080/time-unauth"
      auth_realm[] = "time_auth_proxy",
    }.

    realm_by_name["time_auth_proxy"] = x,
    realm(x) {
      realm_config[] = "default-password"
    }.

  })
} <-- .

Transparent Proxies.  The following example illustrates how to use a transparent proxy. A request to /promo/foo on this host will be forwarded to http://example.com/foo. The host option is used for virtual host support. By setting the host, the HTTP header Host will be set in the forwarded request. The prefix option indicates what prefix of the original URL should be removed from the forwarded request.

block(`service_config) {

  alias_all(`lb:web:config:service),
  alias_all(`lb:web:config:service_abbr),
  alias_all(`lb:web:config:proxy),

  clauses(`{

    service_by_prefix["/promo/*"] = x,
    transparent_proxy(x) {
      proxy_target[] = "http://example.com",
      proxy_host[] = "example.com",
      proxy_prefix[] = "/promo"
    }.

  })
} <-- . 

Authentication.  ServiceBlox proxies do not currently support proxying to authenticated services. For stateful session authentication this is not possible, for RSA-SHA512 authentication there are some small problems that prevent this from working.