Jetty Logo
Version: 9.2.9-SNAPSHOT
Contact the core Jetty developers at

private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery

Configuring SPDY Proxy

Configuring SPDY by Example
An Example Configuration for a SPDY to HTTP Proxy

Configuring SPDY by Example

spdy-jetty-http provides a fully functional SPDY proxy server out of the box. Jetty's SPDY proxy can receive SPDY (currently v2/v3) and HTTP requests, and proxy those requests to other SPDY servers. If necessary, an implementation of the Proxy Engine class translates the incoming protocol to a protocol the target host understands. Currently we provide a SPDYProxyEngine that can talk SPDY v2 and SPDY v3. We plan to support other protocols soon. As always, contributions are welcome.

Configuring SPDY is straightforward, as the following example shows. The example server has a plain SPDY connector listening on port 9090 and a SPDY proxy connector listening on port 8080. Incoming requests to port 8080 are proxied and translated to the connector listening on port 9090. In real world scenarios you more likely proxy to a different host.

Let's take this apart:

This is the ProxyEngineSelector. The ProxyEngineSelector keeps the configurations for the known target hosts and also chooses the right ProxyEngine for the protocol the target host speaks.

Let's take even smaller parts of the snipplet above to explain them in detail:

This adds the SPDYProxyEngine configured above to the ProxyEngineSelector. The SPDYProxyEngine is configured to translate to spdy/2. By adding it to the Selector, it now knows how to translate to spdy/2.

You configure target hosts and the protocol you want to communicate with them by adding so-called ProxyServerInfos. Key for the map is the hostname. You configure protocol, host, and port for the ProxyServerInfo.

Request flow with the proxy given above:

  • Incoming SPDY Request to https://localhost:8443/ reaches the HTTPSPDYProxyConnector listening on port 8443.

  • HTTPSPDYProxyConnector forwards the request to the ProxyEngineSelector.

  • ProxyEngineSelector reads the Host header's host portion: "localhost".

  • ProxyEngineSelector looks up the host in its ProxyServerInfo mappings. It finds the matching entry, "localhost". (If there is no matching entry it rst the stream).

  • ProxyEngineSelector looks up a ProxyEngine that matches the protocol configured in the ProxyServerInfo it found in the last step and forwards the request to that ProxyEngine.

  • The ProxyEngine translates the request to the given target protocol and proxies it to the target host.

  • All responses are forwarded to the client.

An Example Configuration for a SPDY to HTTP Proxy

spdy-jetty-http provides full proxy functionality as described above. Here's another example configuration for a SPDY to HTTP proxy. This proxy accepts SPDY requests and proxies them to an HTTP server.

This is a very common use case, for example to terminate SPDY on a frontend server when you need to talk plain HTTP to your backend, because either your network hardware needs to inspect HTTP content or your backend is unable to talk SPDY. You have the performance advantages of SPDY over the slow internet with high latencies, and you talk HTTP to your backend as needed.

See an error or something missing? Contribute to this documentation at Github!(Generated: 2015-04-19T01:01:09+00:00)