2012-01-26 17:38:35 +01:00
|
|
|
Spdylay - SPDY C Library
|
|
|
|
========================
|
|
|
|
|
2012-04-25 14:25:51 +02:00
|
|
|
This is an experimental implementation of Google's SPDY protocol in C.
|
|
|
|
|
|
|
|
This library provides SPDY version 2 and 3 framing layer
|
|
|
|
implementation. It does not perform any I/O operations. When the
|
|
|
|
library needs them, it calls the callback functions provided by the
|
|
|
|
application. It also does not include any event polling mechanism, so
|
|
|
|
the application can freely choose the way of handling events. This
|
|
|
|
library code does not depend on any particular SSL library (except for
|
|
|
|
example programs which depend on OpenSSL 1.0.1 or later).
|
|
|
|
|
2012-09-12 15:37:05 +02:00
|
|
|
This project also develops SPDY client, server and proxy on top of
|
2012-09-12 15:40:59 +02:00
|
|
|
Spdylay library. See `SPDY Client and Server Programs`_ section.
|
2012-09-12 15:37:05 +02:00
|
|
|
|
2012-04-25 14:25:51 +02:00
|
|
|
Development Status
|
|
|
|
------------------
|
2012-03-26 16:46:02 +02:00
|
|
|
|
2012-04-05 19:34:55 +02:00
|
|
|
Most of the SPDY/2 and SPDY/3 functionality has been implemented. In
|
|
|
|
both versions, the direct support of server-push has not been
|
2012-03-26 16:46:02 +02:00
|
|
|
available yet. The application can achieve server-push using
|
|
|
|
primitive APIs though.
|
|
|
|
|
|
|
|
As described below, we can create SPDY client and server with the
|
|
|
|
current Spdylay API.
|
2012-02-07 18:13:01 +01:00
|
|
|
|
2012-03-29 17:04:08 +02:00
|
|
|
Requirements
|
|
|
|
------------
|
2012-02-07 18:13:01 +01:00
|
|
|
|
2012-03-28 19:33:34 +02:00
|
|
|
The following packages are needed to build the library:
|
|
|
|
|
|
|
|
* pkg-config >= 0.20
|
2012-04-24 19:46:40 +02:00
|
|
|
* zlib >= 1.2.3
|
|
|
|
|
|
|
|
To build and run the unit test programs, the following packages are
|
|
|
|
needed:
|
|
|
|
|
|
|
|
* cunit >= 2.1
|
2012-03-28 19:33:34 +02:00
|
|
|
|
|
|
|
To build and run the example programs, the following packages are
|
|
|
|
needed:
|
|
|
|
|
|
|
|
* OpenSSL >= 1.0.1
|
|
|
|
|
2012-05-19 15:05:42 +02:00
|
|
|
To enable ``-a`` option (getting linked assets from the downloaded
|
2012-06-06 18:58:36 +02:00
|
|
|
resouce) in ``spdycat`` (one of the example program), the following
|
2012-05-19 15:05:42 +02:00
|
|
|
packages are needed:
|
|
|
|
|
|
|
|
* libxml2 >= 2.7.7
|
|
|
|
|
2012-06-06 18:58:36 +02:00
|
|
|
To build SPDY/HTTPS to HTTP reverse proxy ``shrpx`` (one of the
|
|
|
|
example program), the following packages are needed:
|
|
|
|
|
|
|
|
* libevent-openssl >= 2.0.8
|
|
|
|
|
2012-07-15 14:54:55 +02:00
|
|
|
If you are using Ubuntu 12.04, you need the following packages
|
|
|
|
installed:
|
|
|
|
|
|
|
|
* autoconf
|
|
|
|
* automake
|
|
|
|
* autotools-dev
|
|
|
|
* libtool
|
|
|
|
* pkg-config
|
|
|
|
* zlib1g-dev
|
|
|
|
* libcunit1-dev
|
|
|
|
* libssl-dev
|
|
|
|
* libxml2-dev
|
|
|
|
* libevent-dev
|
|
|
|
|
2012-03-29 17:04:08 +02:00
|
|
|
Build from git
|
|
|
|
--------------
|
|
|
|
|
2012-02-07 18:13:01 +01:00
|
|
|
Building from git is easy, but please be sure that at least autoconf 2.68 is
|
2012-05-19 15:05:42 +02:00
|
|
|
used::
|
2012-02-07 18:13:01 +01:00
|
|
|
|
|
|
|
$ autoreconf -i
|
|
|
|
$ automake
|
|
|
|
$ autoconf
|
|
|
|
$ ./configure
|
|
|
|
$ make
|
|
|
|
|
2012-05-13 09:33:30 +02:00
|
|
|
Building documentation
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
To build documentation, run::
|
|
|
|
|
|
|
|
$ make html
|
|
|
|
|
|
|
|
The documents will be generated under ``doc/manual/html/``.
|
|
|
|
|
|
|
|
The generated documents will not be installed with ``make install``.
|
|
|
|
|
2012-03-10 16:21:00 +01:00
|
|
|
API
|
|
|
|
---
|
|
|
|
|
2012-03-13 16:49:16 +01:00
|
|
|
The public API reference is available on online. Visit
|
|
|
|
http://spdylay.sourceforge.net/. All public APIs are in
|
|
|
|
*spdylay/spdylay.h*. All public API functions as well as the callback
|
|
|
|
function typedefs are documented.
|
2012-03-10 16:21:00 +01:00
|
|
|
|
2012-09-12 15:40:59 +02:00
|
|
|
SPDY Client and Server Programs
|
|
|
|
-------------------------------
|
2012-02-07 18:13:01 +01:00
|
|
|
|
2012-09-10 15:03:40 +02:00
|
|
|
The *src* directory contains SPDY client and server implementations
|
|
|
|
using Spdylay library. These programs are intended to make sure that
|
|
|
|
Spdylay API is acutally usable for real implementation and also for
|
|
|
|
debugging purposes. Please note that OpenSSL with `NPN
|
2012-02-07 18:13:01 +01:00
|
|
|
<http://technotes.googlecode.com/git/nextprotoneg.html>`_ support is
|
|
|
|
required in order to build and run these programs. At the time of
|
2012-05-09 16:49:11 +02:00
|
|
|
this writing, the OpenSSL 1.0.1 supports NPN.
|
2012-02-07 18:13:01 +01:00
|
|
|
|
2012-06-06 18:58:36 +02:00
|
|
|
Spdycat - SPDY client
|
|
|
|
+++++++++++++++++++++
|
|
|
|
|
2012-05-13 10:13:36 +02:00
|
|
|
The SPDY client is called ``spdycat``. It is a dead simple downloader
|
|
|
|
like wget/curl. It connects to SPDY server and gets resources given in
|
|
|
|
the command-line::
|
|
|
|
|
2012-09-10 15:03:40 +02:00
|
|
|
$ src/spdycat -h
|
2013-02-14 13:30:35 +01:00
|
|
|
Usage: spdycat [-Oansv23] [-t <SECONDS>] [-w <WINDOW_BITS>] [--cert=<CERT>]
|
|
|
|
[--key=<KEY>] [--no-tls] [-d <FILE>] [-m <N>] <URI>...
|
2012-05-13 10:13:36 +02:00
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-v, --verbose Print debug information such as reception/
|
|
|
|
transmission of frames and name/value pairs.
|
|
|
|
-n, --null-out Discard downloaded data.
|
|
|
|
-O, --remote-name Save download data in the current directory.
|
|
|
|
The filename is dereived from URI. If URI
|
|
|
|
ends with '/', 'index.html' is used as a
|
|
|
|
filename. Not implemented yet.
|
|
|
|
-2, --spdy2 Only use SPDY/2.
|
|
|
|
-3, --spdy3 Only use SPDY/3.
|
|
|
|
-t, --timeout=<N> Timeout each request after <N> seconds.
|
|
|
|
-w, --window-bits=<N>
|
|
|
|
Sets the initial window size to 2**<N>.
|
2012-05-19 15:07:51 +02:00
|
|
|
-a, --get-assets Download assets such as stylesheets, images
|
|
|
|
and script files linked from the downloaded
|
|
|
|
resource. Only links whose origins are the
|
|
|
|
same with the linking resource will be
|
|
|
|
downloaded.
|
|
|
|
-s, --stat Print statistics.
|
2013-01-12 08:43:08 +01:00
|
|
|
-H, --header Add a header to the requests.
|
2012-05-13 10:13:36 +02:00
|
|
|
--cert=<CERT> Use the specified client certificate file.
|
|
|
|
The file must be in PEM format.
|
|
|
|
--key=<KEY> Use the client private key file. The file
|
|
|
|
must be in PEM format.
|
2013-01-12 08:43:08 +01:00
|
|
|
--no-tls Disable SSL/TLS. Use -2 or -3 to specify
|
|
|
|
SPDY protocol version to use.
|
|
|
|
-d, --data=<FILE> Post FILE to server. If - is given, data
|
|
|
|
will be read from stdin.
|
2013-02-14 13:30:35 +01:00
|
|
|
-m, --multiply=<N> Request each URI <N> times. By default, same
|
|
|
|
URI is not requested twice. This option
|
|
|
|
disables it too.
|
2013-01-12 08:43:08 +01:00
|
|
|
|
2012-09-10 15:03:40 +02:00
|
|
|
$ src/spdycat -nv https://www.google.com/
|
2012-05-13 10:13:36 +02:00
|
|
|
[ 0.025] NPN select next protocol: the remote server offers:
|
|
|
|
* spdy/3
|
2012-02-01 16:45:02 +01:00
|
|
|
* spdy/2
|
|
|
|
* http/1.1
|
2012-05-13 10:13:36 +02:00
|
|
|
NPN selected the protocol: spdy/3
|
|
|
|
[ 0.035] recv SETTINGS frame <version=3, flags=0, length=20>
|
|
|
|
(niv=2)
|
2012-02-01 16:45:02 +01:00
|
|
|
[4(1):100]
|
2012-05-13 10:13:36 +02:00
|
|
|
[7(0):12288]
|
|
|
|
[ 0.035] send SYN_STREAM frame <version=3, flags=1, length=106>
|
2012-02-01 16:45:02 +01:00
|
|
|
(stream_id=1, assoc_stream_id=0, pri=3)
|
2012-05-13 10:13:36 +02:00
|
|
|
:host: www.google.com
|
|
|
|
:method: GET
|
|
|
|
:path: /
|
|
|
|
:scheme: https
|
|
|
|
:version: HTTP/1.1
|
|
|
|
accept: */*
|
|
|
|
user-agent: spdylay/0.2.0
|
|
|
|
[ 0.077] recv SYN_REPLY frame <version=3, flags=0, length=558>
|
2012-02-01 16:45:02 +01:00
|
|
|
(stream_id=1)
|
2012-05-13 10:13:36 +02:00
|
|
|
:status: 302 Found
|
|
|
|
:version: HTTP/1.1
|
|
|
|
cache-control: private
|
|
|
|
content-length: 222
|
|
|
|
content-type: text/html; charset=UTF-8
|
|
|
|
date: Sun, 13 May 2012 08:02:54 GMT
|
|
|
|
location: https://www.google.co.jp/
|
2012-02-01 16:45:02 +01:00
|
|
|
server: gws
|
|
|
|
x-frame-options: SAMEORIGIN
|
|
|
|
x-xss-protection: 1; mode=block
|
2012-05-13 10:13:36 +02:00
|
|
|
[ 0.077] recv DATA frame (stream_id=1, flags=1, length=222)
|
|
|
|
[ 0.077] send GOAWAY frame <version=3, flags=0, length=8>
|
2012-02-01 16:45:02 +01:00
|
|
|
(last_good_stream_id=0)
|
2012-01-31 18:39:04 +01:00
|
|
|
|
2012-06-06 18:58:36 +02:00
|
|
|
Spdyd - SPDY server
|
|
|
|
+++++++++++++++++++
|
|
|
|
|
2012-05-28 14:25:44 +02:00
|
|
|
SPDY server is called ``spdyd`` and serves static files. It is single
|
|
|
|
threaded and multiplexes connections using non-blocking socket. The
|
2012-09-10 15:03:40 +02:00
|
|
|
static files are read using blocking I/O system call, ``read(2)``. It
|
2012-05-28 14:25:44 +02:00
|
|
|
speaks SPDY/2 and SPDY/3::
|
2012-02-26 10:25:59 +01:00
|
|
|
|
2012-09-10 15:03:40 +02:00
|
|
|
$ src/spdyd --htdocs=/your/htdocs/ -v 3000 server.key server.crt
|
2012-05-13 10:13:36 +02:00
|
|
|
IPv4: listen on port 3000
|
|
|
|
IPv6: listen on port 3000
|
|
|
|
The negotiated next protocol: spdy/3
|
|
|
|
[id=1] [ 17.456] send SETTINGS frame <version=3, flags=0, length=12>
|
|
|
|
(niv=1)
|
|
|
|
[4(0):100]
|
|
|
|
[id=1] [ 17.457] recv SYN_STREAM frame <version=3, flags=1, length=108>
|
2012-02-26 10:25:59 +01:00
|
|
|
(stream_id=1, assoc_stream_id=0, pri=3)
|
|
|
|
:host: localhost:3000
|
|
|
|
:method: GET
|
2012-05-13 10:13:36 +02:00
|
|
|
:path: /README
|
2012-02-26 10:25:59 +01:00
|
|
|
:scheme: https
|
|
|
|
:version: HTTP/1.1
|
2012-05-13 10:13:36 +02:00
|
|
|
accept: */*
|
|
|
|
user-agent: spdylay/0.2.0
|
|
|
|
[id=1] [ 17.457] send SYN_REPLY frame <version=3, flags=0, length=113>
|
2012-02-26 10:25:59 +01:00
|
|
|
(stream_id=1)
|
2012-05-13 10:13:36 +02:00
|
|
|
:status: 200 OK
|
2012-02-26 10:25:59 +01:00
|
|
|
:version: HTTP/1.1
|
|
|
|
cache-control: max-age=3600
|
2012-05-13 10:13:36 +02:00
|
|
|
content-length: 15
|
|
|
|
date: Sun, 13 May 2012 08:06:12 GMT
|
|
|
|
last-modified: Tue, 17 Jan 2012 15:39:01 GMT
|
|
|
|
server: spdyd spdylay/0.2.0
|
|
|
|
[id=1] [ 17.467] send DATA frame (stream_id=1, flags=0, length=15)
|
|
|
|
[id=1] [ 17.467] send DATA frame (stream_id=1, flags=1, length=0)
|
|
|
|
[id=1] [ 17.468] stream_id=1 closed
|
|
|
|
[id=1] [ 17.468] recv GOAWAY frame <version=3, flags=0, length=8>
|
2012-02-07 18:13:01 +01:00
|
|
|
(last_good_stream_id=0)
|
2012-05-13 10:13:36 +02:00
|
|
|
[id=1] [ 17.468] closed
|
2012-01-31 19:09:42 +01:00
|
|
|
|
2012-02-09 18:29:41 +01:00
|
|
|
Currently, ``spdyd`` needs ``epoll`` or ``kqueue``.
|
2012-02-14 16:04:16 +01:00
|
|
|
|
2012-06-06 18:58:36 +02:00
|
|
|
Shrpx - A reverse proxy for SPDY/HTTPS
|
|
|
|
++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
|
|
|
The ``shrpx`` is a multi-threaded reverse proxy for SPDY/HTTPS. It
|
2013-02-09 13:17:49 +01:00
|
|
|
converts SPDY/HTTPS traffic to plain HTTP. It is initially developed
|
|
|
|
as a reverse proxy, but now it has other operation modes such as a
|
|
|
|
frontend forward proxy. For example, with ``--spdy-proxy`` (``-s`` in
|
|
|
|
shorthand) option, it can be used as secure SPDY proxy with a proxy
|
|
|
|
(e.g., Squid) in the backend. With ``--cliet-proxy`` (``-p``) option,
|
|
|
|
it acts like an ordinaly forward proxy but expects secure SPDY proxy
|
|
|
|
in the backend. Thus it becomes an adapter to secure SPDY proxy for
|
|
|
|
clients which does not support secure SPDY proxy. The another notable
|
|
|
|
operation mode is ``--spdy-relay``, which just relays SPDY/HTTPS
|
|
|
|
traffic to the backend in SPDY. The following table summarizes the
|
|
|
|
operation modes.
|
|
|
|
|
|
|
|
================== ========== ======= =============
|
|
|
|
Mode option Frontend Backend Note
|
|
|
|
================== ========== ======= =============
|
|
|
|
default SPDY/HTTPS HTTP Reverse proxy
|
|
|
|
``--spdy`` SPDY/HTTPS HTTP SPDY proxy
|
|
|
|
``--spdy-relay`` SPDY/HTTPS SPDY
|
|
|
|
``--client`` HTTP SPDY
|
|
|
|
``--client-proxy`` HTTP SPDY Forward proxy
|
|
|
|
================== ========== ======= =============
|
|
|
|
|
|
|
|
The ``shrpx`` supports configuration file. See ``--conf`` option and
|
|
|
|
sample configuration file ``shrpx.conf.sample``.
|
2012-06-06 18:58:36 +02:00
|
|
|
|
2012-09-12 14:39:09 +02:00
|
|
|
We briefly describe the architecture of ``shrpx`` here. It has a
|
|
|
|
dedicated thread which listens on server sockets. When it accepted
|
|
|
|
the incoming connection, it passes the file descriptor of the incoming
|
|
|
|
connection to one of the worker thread. Each worker thread has its
|
|
|
|
own event loop and can handle many connections using non-blocking I/O.
|
|
|
|
The number of worker thread can be specified using the command-line
|
|
|
|
option. The `libevent <http://libevent.org/>`_ is used to handle
|
|
|
|
low-level network I/O.
|
|
|
|
|
2012-06-06 18:58:36 +02:00
|
|
|
Here is the command-line options::
|
|
|
|
|
2012-09-10 15:03:40 +02:00
|
|
|
$ src/shrpx -h
|
2012-11-22 16:26:48 +01:00
|
|
|
Usage: shrpx [-Dh] [-s|--client|-p] [-b <HOST,PORT>]
|
2013-02-09 13:17:49 +01:00
|
|
|
[-f <HOST,PORT>] [-n <CORES>] [-c <NUM>] [-L <LEVEL>]
|
|
|
|
[OPTIONS...] [<PRIVATE_KEY> <CERT>]
|
2012-11-18 13:57:04 +01:00
|
|
|
|
2012-06-06 18:58:36 +02:00
|
|
|
A reverse proxy for SPDY/HTTPS.
|
|
|
|
|
2012-11-22 16:26:48 +01:00
|
|
|
Positional arguments:
|
2013-02-09 13:17:49 +01:00
|
|
|
<PRIVATE_KEY> Set path to server's private key. Required
|
|
|
|
unless either -p or --client is specified.
|
|
|
|
<CERT> Set path to server's certificate. Required
|
|
|
|
unless either -p or --client is specified.
|
2012-06-06 18:58:36 +02:00
|
|
|
|
|
|
|
OPTIONS:
|
2012-11-22 16:26:48 +01:00
|
|
|
|
|
|
|
Connections:
|
2013-02-09 13:17:49 +01:00
|
|
|
-b, --backend=<HOST,PORT>
|
|
|
|
Set backend host and port.
|
|
|
|
Default: '127.0.0.1,80'
|
|
|
|
-f, --frontend=<HOST,PORT>
|
|
|
|
Set frontend host and port.
|
|
|
|
Default: '0.0.0.0,3000'
|
|
|
|
--backlog=<NUM> Set listen backlog size.
|
|
|
|
Default: 256
|
|
|
|
--backend-ipv4 Resolve backend hostname to IPv4 address
|
|
|
|
only.
|
|
|
|
--backend-ipv6 Resolve backend hostname to IPv6 address
|
|
|
|
only.
|
2012-11-22 16:26:48 +01:00
|
|
|
|
|
|
|
Performance:
|
2013-02-09 13:17:49 +01:00
|
|
|
-n, --workers=<CORES>
|
|
|
|
Set the number of worker threads.
|
|
|
|
Default: 1
|
2012-11-22 16:26:48 +01:00
|
|
|
|
|
|
|
Timeout:
|
2013-02-09 13:17:49 +01:00
|
|
|
--frontend-spdy-read-timeout=<SEC>
|
|
|
|
Specify read timeout for SPDY frontend
|
|
|
|
connection. Default: 180
|
|
|
|
--frontend-read-timeout=<SEC>
|
|
|
|
Specify read timeout for non-SPDY frontend
|
|
|
|
connection. Default: 180
|
|
|
|
--frontend-write-timeout=<SEC>
|
|
|
|
Specify write timeout for both SPDY and
|
|
|
|
non-SPDY frontends.
|
|
|
|
connection. Default: 60
|
|
|
|
--backend-read-timeout=<SEC>
|
|
|
|
Specify read timeout for backend connection.
|
|
|
|
Default: 900
|
|
|
|
--backend-write-timeout=<SEC>
|
|
|
|
Specify write timeout for backend
|
|
|
|
connection. Default: 60
|
|
|
|
--backend-keep-alive-timeout=<SEC>
|
|
|
|
Specify keep-alive timeout for backend
|
|
|
|
connection. Default: 60
|
|
|
|
--backend-http-proxy-uri=<URI>
|
|
|
|
Specify proxy URI in the form
|
|
|
|
http://[<USER>:<PASS>@]<PROXY>:<PORT>. If
|
|
|
|
a proxy requires authentication, specify
|
|
|
|
<USER> and <PASS>. Note that they must be
|
|
|
|
properly percent-encoded. This proxy is used
|
|
|
|
when the backend connection is SPDY. First,
|
|
|
|
make a CONNECT request to the proxy and
|
|
|
|
it connects to the backend on behalf of
|
|
|
|
shrpx. This forms tunnel. After that, shrpx
|
|
|
|
performs SSL/TLS handshake with the
|
|
|
|
downstream through the tunnel. The timeouts
|
|
|
|
when connecting and making CONNECT request
|
|
|
|
can be specified by --backend-read-timeout
|
|
|
|
and --backend-write-timeout options.
|
2012-11-22 16:26:48 +01:00
|
|
|
|
|
|
|
SSL/TLS:
|
2013-02-09 13:17:49 +01:00
|
|
|
--ciphers=<SUITE> Set allowed cipher list. The format of the
|
|
|
|
string is described in OpenSSL ciphers(1).
|
|
|
|
-k, --insecure When used with -p or --client, don't verify
|
|
|
|
backend server's certificate.
|
|
|
|
--cacert=<PATH> When used with -p or --client, set path to
|
|
|
|
trusted CA certificate file.
|
|
|
|
The file must be in PEM format. It can
|
|
|
|
contain multiple certificates. If the
|
|
|
|
linked OpenSSL is configured to load system
|
|
|
|
wide certificates, they are loaded
|
|
|
|
at startup regardless of this option.
|
|
|
|
--private-key-passwd-file=<FILEPATH>
|
|
|
|
Path to file that contains password for the
|
|
|
|
server's private key. If none is given and
|
|
|
|
the private key is password protected it'll
|
|
|
|
be requested interactively.
|
|
|
|
--subcert=<KEYPATH>:<CERTPATH>
|
|
|
|
Specify additional certificate and private
|
|
|
|
key file. Shrpx will choose certificates
|
|
|
|
used multiple times.
|
2012-11-22 16:26:48 +01:00
|
|
|
|
|
|
|
SPDY:
|
2013-02-09 13:17:49 +01:00
|
|
|
-c, --spdy-max-concurrent-streams=<NUM>
|
|
|
|
Set the maximum number of the concurrent
|
|
|
|
streams in one SPDY session.
|
|
|
|
Default: 100
|
|
|
|
--frontend-spdy-window-bits=<N>
|
|
|
|
Sets the initial window size of SPDY
|
|
|
|
frontend connection to 2**<N>.
|
|
|
|
Default: 16
|
|
|
|
--backend-spdy-window-bits=<N>
|
|
|
|
Sets the initial window size of SPDY
|
|
|
|
backend connection to 2**<N>.
|
|
|
|
Default: 16
|
2012-11-22 16:26:48 +01:00
|
|
|
|
|
|
|
Mode:
|
2013-02-09 13:17:49 +01:00
|
|
|
-s, --spdy-proxy Enable secure SPDY proxy mode.
|
|
|
|
--spdy-bridge Communicate with the backend in SPDY. Thus
|
|
|
|
the incoming SPDY/HTTPS connections are
|
|
|
|
converted to SPDY connection and relayed to
|
|
|
|
the backend. See --backend-http-proxy-uri
|
|
|
|
option if you are behind the proxy and want
|
|
|
|
to connect to the outside SPDY proxy.
|
|
|
|
--client Instead of accepting SPDY/HTTPS connection,
|
|
|
|
accept HTTP connection and communicate with
|
|
|
|
backend server in SPDY. To use shrpx as
|
|
|
|
a forward proxy, use -p option instead.
|
|
|
|
-p, --client-proxy Like --client option, but it also requires
|
|
|
|
the request path from frontend must be
|
|
|
|
an absolute URI, suitable for use as a
|
|
|
|
forward proxy.
|
2013-01-12 08:43:08 +01:00
|
|
|
|
2012-11-22 16:26:48 +01:00
|
|
|
Logging:
|
2013-02-09 13:17:49 +01:00
|
|
|
-L, --log-level=<LEVEL>
|
|
|
|
Set the severity level of log output.
|
|
|
|
INFO, WARNING, ERROR and FATAL.
|
|
|
|
Default: WARNING
|
|
|
|
--accesslog Print simple accesslog to stderr.
|
|
|
|
--syslog Send log messages to syslog.
|
|
|
|
--syslog-facility=<FACILITY>
|
|
|
|
Set syslog facility.
|
|
|
|
Default: daemon
|
2012-06-06 18:58:36 +02:00
|
|
|
|
2012-11-22 16:26:48 +01:00
|
|
|
Misc:
|
2013-02-09 13:17:49 +01:00
|
|
|
--add-x-forwarded-for
|
|
|
|
Append X-Forwarded-For header field to the
|
|
|
|
downstream request.
|
|
|
|
--no-via Don't append to Via header field. If Via
|
|
|
|
header field is received, it is left
|
|
|
|
unaltered.
|
|
|
|
-D, --daemon Run in a background. If -D is used, the
|
|
|
|
current working directory is changed to '/'.
|
|
|
|
--pid-file=<PATH> Set path to save PID of this program.
|
|
|
|
--user=<USER> Run this program as USER. This option is
|
|
|
|
intended to be used to drop root privileges.
|
|
|
|
--conf=<PATH> Load configuration from PATH.
|
|
|
|
Default: /etc/shrpx/shrpx.conf
|
|
|
|
-v, --version Print version and exit.
|
|
|
|
-h, --help Print this help and exit.
|
2012-07-12 16:59:05 +02:00
|
|
|
|
2012-06-06 18:58:36 +02:00
|
|
|
For those of you who are curious, ``shrpx`` is an abbreviation of
|
|
|
|
"Spdy/https to Http Reverse ProXy".
|
|
|
|
|
2013-02-09 13:17:49 +01:00
|
|
|
Without any of ``-s``, ``--spdy-bridge``, ``-p`` and ``--client``
|
|
|
|
options, ``shrpx`` works as reverse proxy to the backend server::
|
2012-07-15 14:54:55 +02:00
|
|
|
|
2012-09-10 15:03:40 +02:00
|
|
|
Client <-- (SPDY, HTTPS) --> Shrpx <-- (HTTP) --> Web Server
|
2012-11-22 16:26:48 +01:00
|
|
|
[reverse proxy]
|
2012-07-15 14:54:55 +02:00
|
|
|
|
2012-11-22 16:26:48 +01:00
|
|
|
With ``-s`` option, it works as secure SPDY proxy::
|
2012-07-15 14:54:55 +02:00
|
|
|
|
2012-11-22 16:26:48 +01:00
|
|
|
Client <-- (SPDY, HTTPS) --> Shrpx <-- (HTTP) --> Proxy
|
|
|
|
[SPDY proxy] (e.g., Squid)
|
2012-07-15 14:54:55 +02:00
|
|
|
|
2013-02-09 13:17:49 +01:00
|
|
|
The ``Client`` in the above is needs to be configured to use shrpx as
|
|
|
|
secure SPDY proxy.
|
2012-07-15 14:54:55 +02:00
|
|
|
|
|
|
|
At the time of this writing, Chrome is the only browser which supports
|
2012-11-22 16:26:48 +01:00
|
|
|
secure SPDY proxy. The one way to configure Chrome to use secure SPDY
|
|
|
|
proxy is create proxy.pac script like this::
|
2012-07-15 14:54:55 +02:00
|
|
|
|
|
|
|
function FindProxyForURL(url, host) {
|
|
|
|
return "HTTPS SERVERADDR:PORT";
|
|
|
|
}
|
|
|
|
|
|
|
|
``SERVERADDR`` and ``PORT`` is the hostname/address and port of the
|
|
|
|
machine shrpx is running. Please note that Chrome requires valid
|
2012-11-22 16:26:48 +01:00
|
|
|
certificate for secure SPDY proxy.
|
2012-07-15 14:54:55 +02:00
|
|
|
|
|
|
|
Then run chrome with the following arguments::
|
|
|
|
|
|
|
|
$ google-chrome --proxy-pac-url=file:///path/to/proxy.pac --use-npn
|
|
|
|
|
2013-02-09 13:17:49 +01:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
At the time of this writing, Chrome 24 limits the maximum
|
|
|
|
concurrent connections to the proxy to 32. And due to the
|
|
|
|
limitation of socket pool handling in Chrome, it is quickly filled
|
|
|
|
up if SPDY proxy is used and many SPDY sessions are established. If
|
|
|
|
it reaches the limit, the new connections are simply blocked until
|
|
|
|
existing connections are timed out. (See `Chrome Issue 92244
|
|
|
|
<https://code.google.com/p/chromium/issues/detail?id=92244>`_). The
|
|
|
|
workaround is make the number of maximum connections high, say, 99,
|
|
|
|
which is the highest. To do this, you need to change so called
|
|
|
|
Policy setup. See `Policy Templates
|
|
|
|
<http://dev.chromium.org/administrators/policy-templates>`_ for
|
|
|
|
details how to change Policy setup on the platform you use. The
|
|
|
|
Policy name we are looking for is `MaxConnectionsPerProxy
|
|
|
|
<http://dev.chromium.org/administrators/policy-list-3#MaxConnectionsPerProxy>`_
|
|
|
|
For example, if you are using Linux, follow the instruction
|
|
|
|
described in `Linux Quick Start
|
|
|
|
<http://dev.chromium.org/administrators/linux-quick-start>`_ and
|
|
|
|
create ``/etc/opt/chrome/policies/managed/test_policy.json`` file
|
|
|
|
with the following content and restart Chrome::
|
|
|
|
|
|
|
|
{
|
|
|
|
"MaxConnectionsPerProxy" :99
|
|
|
|
}
|
|
|
|
|
|
|
|
With ``--spdy-bridge``, it accepts SPDY/HTTPS connections and
|
|
|
|
communicates with backend in SPDY::
|
|
|
|
|
|
|
|
Client <-- (SPDY, HTTPS) --> Shrpx <-- (SPDY) --> Web or SPDY Proxy etc
|
|
|
|
[SPDY bridge] (e.g., shrpx -s)
|
|
|
|
|
2012-11-22 16:26:48 +01:00
|
|
|
With ``-p`` option, it works as forward proxy and expects that the
|
|
|
|
backend is secure SPDY proxy::
|
|
|
|
|
|
|
|
Client <-- (HTTP) --> Shrpx <-- (SPDY) --> Secure SPDY Proxy
|
|
|
|
[forward proxy] (e.g., shrpx -s or node-spdyproxy)
|
|
|
|
|
2013-02-09 13:17:49 +01:00
|
|
|
The ``Client`` is needs to be configured to use shrpx as forward proxy.
|
2012-11-22 16:26:48 +01:00
|
|
|
|
|
|
|
In this configuration, clients which do not support secure SPDY proxy
|
|
|
|
can use secure SPDY proxy through ``shrpx``. Putting ``shrpx`` in the
|
|
|
|
same box or same network with the clients, this configuration can
|
2012-11-24 12:28:07 +01:00
|
|
|
bring the benefits of secure SPDY proxy to those clients. Since the
|
|
|
|
maximum number of connections per server still applies in proxy
|
|
|
|
connection, the performance gain is not obvious. For example, if the
|
|
|
|
maximum number of connections per server is 6, after sending 6
|
|
|
|
requests to the proxy, client blocks further requests, which kills
|
|
|
|
performance which might be gained in SPDY connection. For clients
|
|
|
|
which can tweak these values (e.g.,
|
|
|
|
``network.http.max-connections-per-server`` in Firefox), increasing
|
|
|
|
them may improve the performance.
|
2012-11-18 13:57:04 +01:00
|
|
|
|
2012-11-22 16:26:48 +01:00
|
|
|
With ``--client`` option, it works as reverse proxy and expects that
|
|
|
|
the backend is SPDY-enabled Web server::
|
2012-11-18 13:57:04 +01:00
|
|
|
|
2012-11-22 16:26:48 +01:00
|
|
|
Client <-- (HTTP) --> Shrpx <-- (SPDY) --> Web Server
|
|
|
|
[reverse proxy]
|
2012-07-15 14:54:55 +02:00
|
|
|
|
2013-02-09 13:17:49 +01:00
|
|
|
For the operation modes which talk to the backend in SPDY, the backend
|
|
|
|
connections can be tunneled though HTTP proxy. The proxy is specified
|
|
|
|
using ``--backend-http-proxy-uri`` option. The following figure
|
|
|
|
illustrates the example of ``--spdy-bridge`` and
|
|
|
|
``--backend-http-proxy-uri`` option to talk to the outside SPDY proxy
|
|
|
|
through HTTP proxy::
|
|
|
|
|
|
|
|
Client <-- (SPDY, HTTPS) --> Shrpx <-- (SPDY) --
|
|
|
|
[SPDY bridge]
|
|
|
|
|
|
|
|
--===================---> SPDY Proxy
|
|
|
|
(HTTP proxy tunnel) (e.g., shrpx -s)
|
|
|
|
|
2012-09-10 15:03:40 +02:00
|
|
|
Examples
|
|
|
|
--------
|
2012-05-13 10:13:36 +02:00
|
|
|
|
2012-09-10 15:03:40 +02:00
|
|
|
The *examples* directory contains a simple SPDY client implementation
|
|
|
|
in C.
|
2012-08-16 18:38:44 +02:00
|
|
|
|
2012-09-10 15:03:40 +02:00
|
|
|
Python-Spdylay - Python Wrapper
|
|
|
|
-------------------------------
|
2012-08-16 18:38:44 +02:00
|
|
|
|
2012-09-10 15:03:40 +02:00
|
|
|
The library comes with Python wrapper ``python-spdylay``. See
|
|
|
|
``python`` directory.
|