Skip to content
Newer
Older
100644 97 lines (64 sloc) 5.54 KB
c367544 @igrigorik first pass over readme
authored
1 # SPDY Proxy
2
31d2486 @igrigorik readme improvements
authored
3 Google Chrome supports SPDY/HTTPS as a forward proxy type, which allow us to use Chrome in a number of use cases where HTTP proxies could not have been used before. When using an HTTPS proxy in Chrome, instead of sending a `CONNECT` request in cleartext and then creating the SSL tunnel (hence leaking information about the site we're connecting to), the browser and the proxy first negotiate an SSL session, and then the browser sends the proxy request. Hence, all communication is always encrypted over SSL, and nobody can listen in on what your browser is requesting ([read more][spdy-vpn]). Use cases:
4
5 * End-to-end secure browsing for *all* sites (HTTP, HTTPS, SPDY) - no sniffing!
6 * Web VPN: secure access to internal servers and services without relying on heavy TCP VPN solutions
c367544 @igrigorik first pass over readme
authored
7
25d3bd1 @igrigorik add PAC examples
authored
8 Where does SPDY fit in here? When the SSL handshake is done, the browser and the server can agree to establish a SPDY session by using [SSL NPN][npn] ([RFC][npn-rfc]). If both sides support SPDY, then all communication between browser and proxy can be done over SPDY:
c367544 @igrigorik first pass over readme
authored
9
5b37d9b @igrigorik camo + akamai is a pain..
authored
10 ![SPDY Proxy Diagram](http://www.igvita.com/posts/12/spdyproxy-diagram.png?akamai=bah)
c367544 @igrigorik first pass over readme
authored
11
31d2486 @igrigorik readme improvements
authored
12 * All browser <-> proxy communication is done over SSL
13 * SPDY Proxy and Chrome communicate via SPDY (v2)
c367544 @igrigorik first pass over readme
authored
14 * Browser requests are routed via SPDY proxy to destination
15
31d2486 @igrigorik readme improvements
authored
16 Notice that we can route both HTTP and HTTPS requests through the SPDY tunnel. To establish an HTTPS session, the browser sends a `CONNECT` request to the proxy with the hostname of the secure server (ex, https://google.com), the proxy establishes the TCP connection and then simply transfers the encrypted bytes between the streams - the proxy only knows that you wanted to connect to Google, but cannot see any of your actual traffic - we're tunneling SSL over SSL!
c367544 @igrigorik first pass over readme
authored
17
18 Same logic applies for tunelling SPDY! We can establish a SPDY v2 tunnel to the proxy, and then tunnel SPDY v3 connections over it.
19
20 ## Installation & Configuration
21
604ef0f @igrigorik woot, can use 0.8.0, no need for custom builds!
authored
22 SPDY proxy requires node.js 0.8.x+. Grab the [package for your platform](http://nodejs.org/) from the node site. Once node.js is installed, you can use npm (node package manager) to install SPDY Proxy:
c367544 @igrigorik first pass over readme
authored
23
24 ```bash
25 $> npm install -g spdyproxy
26 $> spdyproxy --help
27 ```
28
29 To run the proxy, you need to provide your SSL keys:
30
31 ```bash
d328d50 @igrigorik add SSL key instructions + sample localhost keys
authored
32 $> spdyproxy -k keys/mykey.pem -c keys/mycert.pem -p 44300
c367544 @igrigorik first pass over readme
authored
33 ```
34
35 With that, you should have a SPDY proxy running on port 44300.
36
37 ## Configuring Google Chrome
38
39 Google Chrome uses PAC (proxy auto-config) files to choose the appropriate proxy server for fetching any URL. The PAC file itself, is just a simple JavaScript function:
40
41 ```javascript
42 function FindProxyForURL(url, host) {
43 return "HTTPS proxy.example.com:8080; DIRECT";
44 }
45 ```
46
25d3bd1 @igrigorik add PAC examples
authored
47 The above file tells the browser to proxy all requests via a secure proxy on port 8080, and if the proxy fails, then try to connect directly to the host. However, the PAC file allows us to create *much* more interesting scenarios: proxy specific URLs or hostnames, proxy rules based on DNS resolution results, and more. See [PAC directory](https://github.com/igrigorik/node-spdyproxy/tree/master/pac) for examples.
c367544 @igrigorik first pass over readme
authored
48
49 ## DIY demo setup
50
31d2486 @igrigorik readme improvements
authored
51 To do a quick local test, start the SPDY proxy on your machine, and start Chrome with the `--proxy-pac-url` flag:
c367544 @igrigorik first pass over readme
authored
52
53 ```bash
d328d50 @igrigorik add SSL key instructions + sample localhost keys
authored
54 $> spdyproxy -k keys/mykey.pem -c keys/mycert.pem -p 44300 -v
25d3bd1 @igrigorik add PAC examples
authored
55 $> "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --proxy-pac-url=file:///path/to/config.pac --use-npn
c367544 @igrigorik first pass over readme
authored
56 ```
57
ea4d63b @igrigorik add images to readme
authored
58 ![SPDY Proxy](http://www.igvita.com/posts/12/spdyproxy-demo.png)
59
c367544 @igrigorik first pass over readme
authored
60 ## Securing the proxy
61
d328d50 @igrigorik add SSL key instructions + sample localhost keys
authored
62 To run a secure (SPDY) proxy your will need a valid SSL certificate on the server, and also make sure that your client will accept this certificate without any errors. If you're generating a self-signed certificate, then you will need to manually import it into your client keychain - otherwise, the browser will terminate the connection. To create a self-signed certificate:
c367544 @igrigorik first pass over readme
authored
63
64 ```bash
d328d50 @igrigorik add SSL key instructions + sample localhost keys
authored
65 $> openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mykey.pem -out mycert.pem
66
67 # on OSX, you now need to manually add mycert.pem to your keychain (for local testing)
68 # -> lauch Keychain app, drag the key into the app, and mark it as accepted
c367544 @igrigorik first pass over readme
authored
69 ```
70
31d2486 @igrigorik readme improvements
authored
71 Once the proxy server is running, it is accessible by any client that wants to use it. To restrict access, you can use regular firewall rules, IP blacklists, etc. Alternatively, SPDY proxy supports `Basic-Auth` proxy authentication. Recall that all communication between client and server is done over SSL, hence all auth data is secure! The first time your browser connects to the proxy, it will ask for a login and password. After that, the browser will automatically append the authentication headers.
c367544 @igrigorik first pass over readme
authored
72
25d3bd1 @igrigorik add PAC examples
authored
73 ```bash
74 # pass in -U and -P flags to spdyproxy to set the Basic-Auth username and password
d328d50 @igrigorik add SSL key instructions + sample localhost keys
authored
75 $> spdyproxy -k keys/mykey.pem -c keys/mycert.pem -p 44300 -U user -P pass
25d3bd1 @igrigorik add PAC examples
authored
76 ```
c367544 @igrigorik first pass over readme
authored
77
78 ### Other resources
79
80 * [Web VPN: Secure proxies with SPDY & Chrome][spdy-vpn]
81 * [SPDY proxy examples on chromium.org][spdy-examples]
604ef0f @igrigorik woot, can use 0.8.0, no need for custom builds!
authored
82 * [Proxy Auto Configuration][pac]
d328d50 @igrigorik add SSL key instructions + sample localhost keys
authored
83 * [Creating an SSL Certificate Signing Request][csr]
84 * [Creating a Self-Signed SSL Certificate][self-signed]
c367544 @igrigorik first pass over readme
authored
85
d328d50 @igrigorik add SSL key instructions + sample localhost keys
authored
86 ### License
87
88 (MIT License) - Copyright (c) 2012 Ilya Grigorik
c367544 @igrigorik first pass over readme
authored
89
90 [spdy-vpn]: http://www.igvita.com/2011/12/01/web-vpn-secure-proxies-with-spdy-chrome/
25d3bd1 @igrigorik add PAC examples
authored
91 [npn]: https://technotes.googlecode.com/git/nextprotoneg.html
92 [npn-rfc]: http://tools.ietf.org/html/draft-agl-tls-nextprotoneg-00
c367544 @igrigorik first pass over readme
authored
93 [pac]: http://en.wikipedia.org/wiki/Proxy_auto-config
94 [spdy-examples]: http://dev.chromium.org/spdy/spdy-proxy-examples
d328d50 @igrigorik add SSL key instructions + sample localhost keys
authored
95 [csr]: https://devcenter.heroku.com/articles/csr)
96 [self-signed]: https://devcenter.heroku.com/articles/ssl-certificate-self
Something went wrong with that request. Please try again.