Git Product home page Git Product logo

node-spdyproxy's Introduction

SPDY Proxy

Google Chrome comes with built-in support for SSL-based proxies, which means that we can give Chrome an HTTPS proxy URL, and the rest is taken care of: a TLS tunnel is first established to the proxy, and the proxied requests are sent over a secure link. No eavesdropping allowed! This is a huge improvement over regular HTTP proxies, which can also tunnel SSL, but in the process leak information about the site we're connecting to - read more about Chrome and secure proxies. This allow a number of new and interesting use cases:

  • End-to-end secure browsing for all sites (HTTP, HTTPS, SPDY) - no sniffing!
  • Web VPN: secure access to internal servers and services without relying on heavy TCP VPN solutions

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 (RFC). If both sides support SPDY, then all communication between browser and proxy can be done over SPDY:

SPDY Proxy Diagram

  • All browser <-> proxy communication is done over SSL
  • SPDY Proxy and Chrome communicate via SPDY (v2)
  • Browser requests are routed via SPDY proxy to destination

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!

Same logic applies for tunneling SPDY! We can establish a SPDY v2 tunnel to the proxy, and then tunnel SPDY v3 connections over it.

Installation & Configuration

SPDY proxy requires node.js 0.8.x+. Grab the package for your platform from the node site. Once node.js is installed, you can use npm (node package manager) to install SPDY Proxy:

$> npm install -g spdyproxy
$> spdyproxy --help

To run the proxy, you need to provide your SSL keys:

$> spdyproxy -k keys/mykey.pem -c keys/mycert.pem -p 44300

With that, you should have a SPDY proxy running on port 44300.

Configuring Google Chrome

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:

function FindProxyForURL(url, host) {
  return "HTTPS proxy.example.com:8080; DIRECT";
}

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 for examples.

DIY demo setup

To do a quick local test, start the SPDY proxy on your machine, and start Chrome with the --proxy-pac-url flag:

$> spdyproxy -k keys/mykey.pem -c keys/mycert.pem -p 44300 -v
$> "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --proxy-pac-url=file:///path/to/config.pac --use-npn

SPDY Proxy

Securing the proxy

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:

$> openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mykey.pem -out mycert.pem

# on OSX, you now need to manually add mycert.pem to your keychain (for local testing)
# -> lauch Keychain app, drag the key into the app, and mark it as accepted

Protip: You can get a free, signed SSL certificate for your domain via StartSSL.

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.

# pass in -U and -P flags to spdyproxy to set the Basic-Auth username and password
$> spdyproxy -k keys/mykey.pem -c keys/mycert.pem -p 44300 -U user -P pass

Two way SSL authentication

SPDY proxy server authenticate client by SSL certificate.

#generate key and CSR for client
openssl req -out client1.csr -new -newkey rsa:2048 -nodes -keyout client1.pem
#sign client CSR using server's key, use -CAserial mycert.srl if serial file alreday exists otherwise use -CAcreateserial
openssl x509 -req -in client1.csr -CA mycert.pem -CAkey mykey.pem -CAcreateserial -out client1.cer
#export client certificate to pfx file so that it can be imported into client's browsers manually
openssl pkcs12 -export -out client1.pfx -inkey client1.pem -in client1.cer

Now run the SPDY proxy server as

#use -C and -a to validate client certificate
spdyproxy  -k keys/mykey.pem -c keys/mycert.pem -p 44300  -a keys/mycert.pem -C

To use the proxy server, a client certificate must be presented.

Other resources

License

(MIT License) - Copyright (c) 2012 Ilya Grigorik

node-spdyproxy's People

Contributors

amilajack avatar berstend avatar cai1111 avatar chemhack avatar est avatar fengxx avatar igrigorik avatar indutny avatar jiehanzheng avatar ngbrown avatar piotrsikora avatar ploer avatar ppergame avatar ym avatar yylyyl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-spdyproxy's Issues

WebSocket failed to work

WebSocket failed to work with spdyproxy,

see http://websocketstest.com/ or http://www.websocket.org/echo.html for a test

Trace of failed test(with spdy proxy on):

3493: SOCKET_STREAM
ws://echo.websocket.org/?encoding=text
Start Time: 2013-05-16 18:19:07.586

t=1368721147586 [st=0] +REQUEST_ALIVE [dt=?]
t=1368721147586 [st=0] +SOCKET_STREAM_CONNECT [dt=?]
--> url = "ws://echo.websocket.org/?encoding=text"
t=1368721147587 [st=1] +PROXY_SERVICE [dt=2]
t=1368721147589 [st=3] PROXY_SERVICE_RESOLVED_PROXY_LIST
--> pac_string = "HTTPS lo.1fan.in:4446"
t=1368721147589 [st=3] -PROXY_SERVICE
t=1368721147589 [st=3] HOST_RESOLVER_IMPL [dt=0]
--> source_dependency = 3494 (HOST_RESOLVER_IMPL_REQUEST)

Trace of test with proxy off

3517: SOCKET_STREAM
ws://echo.websocket.org/?encoding=text
Start Time: 2013-05-16 18:20:14.935

t=1368721214935 [st= 0] +REQUEST_ALIVE [dt=?]
t=1368721214935 [st= 0] +SOCKET_STREAM_CONNECT [dt=96]
--> url = "ws://echo.websocket.org/?encoding=text"
t=1368721214935 [st= 0] +PROXY_SERVICE [dt=0]
t=1368721214935 [st= 0] PROXY_SERVICE_RESOLVED_PROXY_LIST
--> pac_string = "DIRECT"
t=1368721214935 [st= 0] -PROXY_SERVICE
t=1368721214935 [st= 0] +PROXY_SERVICE [dt=0]
t=1368721214935 [st= 0] PROXY_SERVICE_RESOLVED_PROXY_LIST
--> pac_string = "DIRECT"
t=1368721214935 [st= 0] -PROXY_SERVICE
t=1368721214935 [st= 0] HOST_RESOLVER_IMPL [dt=1]
--> source_dependency = 3518 (HOST_RESOLVER_IMPL_REQUEST)
t=1368721215031 [st= 96] -SOCKET_STREAM_CONNECT
t=1368721215033 [st= 98] WEB_SOCKET_SEND_REQUEST_HEADERS
--> GET /?encoding=text HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: echo.websocket.org
Origin: http://www.websocket.org
Pragma: no-cache
Cache-Control: no-cache
Sec-WebSocket-Key: 2kFqoccp+Pw2FwpJm4gXzg==
Sec-WebSocket-Version: 13
Sec-WebSocket-Extensions: x-webkit-deflate-frame
Cookie: [212 bytes were stripped]

t=1368721215033 [st= 98] SOCKET_STREAM_SENT
t=1368721215130 [st=195] SOCKET_STREAM_RECEIVED
t=1368721215130 [st=195] WEB_SOCKET_READ_RESPONSE_HEADERS
--> HTTP/1.1 101 Web Socket Protocol Handshake
Upgrade: WebSocket
Connection: Upgrade
Sec-WebSocket-Accept: MSOYPaHm+m9ajD/ZYWXq4SLfwN4=
Server: Kaazing Gateway
Date: Thu, 16 May 2013 16:17:47 GMT
Access-Control-Allow-Origin: http://www.websocket.org
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: content-type
Access-Control-Allow-Headers: authorization
Access-Control-Allow-Headers: x-websocket-extensions
Access-Control-Allow-Headers: x-websocket-version
Access-Control-Allow-Headers: x-websocket-protocol

193mb npm module?

I think some junk has got into your npm module, can you please republish it?

YouTube videos are not being loaded completely (?)

Hi,

I've just played around with spdyproxy and so far everything works great.

However I noticed one issue while using a local spdyproxy and visiting youtube,
the video does get buffered initially but stops buffering around 10-20seconds in.

It happens with every video but let's use this one for example:
http://www.youtube.com/watch?v=Md6Dvxdr0AQ

When I disable the proxy everything works normally.

Can someone confirm this?
(Before I investigate further I'd like to know if it's an local issue on my end).

Im using the latest version from master with the spdy ~1.3 fix.

Thanks!

The connection to the proxy itself didn't use spdy

It doesn't affect the performance, but I am just curious.

Somehow, the connection to the proxy itself (the last row of the connection table in the chrome://net-internals/#spdy) is not in spdy, showing 'unknown' for Protocol Negotiatied, while the connections to the end websites through the proxy are in spdy/v3.

Forced chunked encoding breaks spdyproxy

Accessing flickr.com (via spdyproxy) with new node-spdy breaks some resource fetches:

127.0.0.1:55846 - GET - stream ID: 43 - priority: 1
GET /g/combo/1/3.7.3?autocomplete-list/assets/skins/sam/autocomplete-list.css&c/c_.HO-3.BC.v223Nt&c/c_.JQ.BC.v25xKa&c/c_.CB-.D.BC.v2ah4v&c/c_.LI.BC.v27yEc&c/c_.KQ.W-.D.BC.v27yEc&c/c_.IZ.BC.v26nUg&c/c_.EN_.EQ_.D.BC.v27yEc&c/c_.B-.GE.BC.v27yEc&c/c_.B-.BK-.EO-.D.BC.v27yEc&c/c_.HG-.W.BC.v26ZMi&c/c_.B-.H-.BB.BC.v27yEc&c/c_.IZ-infinite-.JV.BC.v25k3X
 > host: l.yimg.com
 > path: /g/combo/1/3.7.3?autocomplete-list/assets/skins/sam/autocomplete-list.css&c/c_.HO-3.BC.v223Nt&c/c_.JQ.BC.v25xKa&c/c_.CB-.D.BC.v2ah4v&c/c_.LI.BC.v27yEc&c/c_.KQ.W-.D.BC.v27yEc&c/c_.IZ.BC.v26nUg&c/c_.EN_.EQ_.D.BC.v27yEc&c/c_.B-.GE.BC.v27yEc&c/c_.B-.BK-.EO-.D.BC.v27yEc&c/c_.HG-.W.BC.v26ZMi&c/c_.B-.H-.BB.BC.v27yEc&c/c_.IZ-infinite-.JV.BC.v25k3X
 > accept: text/css,*/*;q=0.1
 > accept-encoding: gzip,deflate,sdch
 > accept-language: en-US,en;q=0.8
 > cache-control: no-cache
 > pragma: no-cache
 > referer: http://www.flickr.com/
 > user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1525.0 Safari/537.36
 > transfer-encoding: chunked

200
{ date: 'Thu, 30 May 2013 16:25:13 GMT',
  p3p: 'policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"',
  'last-modified': 'Thu, 30 May 2013 16:25:13 GMT',
  expires: 'Sun, 28 May 2023 16:25:13 GMT',
  'cache-control': 'max-age=315360000,public',
  'x-served-by': 'www315.flickr.mud.yahoo.com',
  vary: 'Accept-Encoding',
  'content-encoding': 'gzip',
  'content-length': '8412',
  'content-type': 'text/css; charset=utf-8',
  age: '280447',
  connection: 'keep-alive',
  via: 'http/1.1 l19.ycs.s2e.yahoo.com (ApacheTrafficServer/3.2.0)',
  server: 'ATS/3.2.0',
  'proxy-agent': 'SPDY Proxy 0.2.4' }
Client error: Parse Error

If I manually disable forceChunked (his._forceChunked = false;), then everything is Ok - hmm. /cc @indutny

getting confused by signed ssl

Hi again,

And sorry for my post, I get my signed ssl from startssl and they gave me 3 file 1 for ssl.crt and 1 for root.pem and 1 for intermediate.pem and after that i put them on my server and start the spdy with my generated key which i used for generating csr for startssl and ssl.crt for my sll one and my server run but i couldn't connect to the server at all. what am i missing here. please help me

Incompatibility with spdy v1.4.0+

Normal http traffic can go through the proxy very well, but https traffic can't.
I followed the installation steps many times: on different vps(event my own PC) , different version of chrome browser, different certs.
The error msg is proxy server :

***.***.123.97:14773 - CONNECT - stream ID: 5
CONNECT www.google.com:443
 > host: www.google.com
 > path: www.google.com:443
 > user-agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.30 (KHTML, li
ke Gecko) Chrome/26.0.1400.0 Safari/537.30

Error: TypeError: Object #<Stream> has no method 'lock'

The chrome://net-internals/#spdy in my chrome:
SPDY Status

SPDY Enabled: true
Use Alternate Protocol: true
Force SPDY Always: false
Force SPDY Over SSL: true
Next Protocols: http/1.1,spdy/2,spdy/3

Node.js version in proxy server is 0.8.18
Chrome version is 26
PC OS is windows 8 64 bit

My PAC file:
function FindProxyForURL(url, host) {
return "HTTPS my.domain:443";
}

Error 136 (net::ERR_PROXY_CERTIFICATE_INVALID): Unknown error.

Hi,

I can't follow your demo to setup my local spdyproxy working on osx.

I already have my certificate in my keychain being trusted. Node is 0.8.9.

spdyproxy running:

spdyproxy -k mykey.pem -c mycert.pem -p 44300 -v
Started SPDY proxy, port: 44300 (v. 0.2.1)

and pac file:

function FindProxyForURL(url, host) {
return "HTTPS 127.0.0.1:44300";
}

and by running chrome, it keep showing:

iTags-MacBook-Pro:~ ccp999$ "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --proxy-pac-url=file://sers/ccp999/config.pac --use-npn
Sep 17 13:58:15 iTags-MacBook-Pro.local Google Chrome Helper[7092] : CGSLookupServerRootPort: Failed to look up the port for "com.apple.windowserver.active" (1100)
Sep 17 13:58:21 iTags-MacBook-Pro.local Google Chrome Helper[7103] : CGSLookupServerRootPort: Failed to look up the port for "com.apple.windowserver.active" (1100)

and when browsing anything: Chrome shows

Error 136 (net::ERR_PROXY_CERTIFICATE_INVALID): Unknown error.

what is wrong?

Thanks in advance!

Brendan

chrome 34's SpdyStream::HALF_CLOSED_REMOTE state causes some sites to fail to load

Specifically, login.microsoftonline.com only partly loads when using chrome 34 through node-spdyproxy. I was able to determine that it was this chromium change that introduced the issue, but I'm not familiar enough with SPDY yet to figure out what the actual problem is.

I tried updating node-spdyproxy to the lastest version of node-spdy but wasn't able to get that working (the handleRequest logging was broken, and after removing that I started getting SSL protocol errors in the browser).

I tried using a different spdy proxy spdylay and that worked fine, so I'm thinking the issue is in node-spdyproxy or node-spdy.

I'll try to debug it further but if anyone has any other suggestions that would be helpful, thanks!

Uncaught TypeError: Cannot call method 'destroy' of undefined

On branch master, an exception will raise (after commenting out the process.on('uncaughtException', ...) block) whenever I keep reloading the YouTube homepage. I am still trying to figure out what exactly on YouTube homepage is causing this exception to raise but it seems to be related to this commit 886ae5c, according to the stack trace attached.

Here is a more helpful stack trace after loading long-stack-traces. The line numbers might be off 60b9ae6 by a few lines since I touched some of the error handling code.

< Uncaught TypeError: Cannot call method 'destroy' of undefined
<     at ClientRequest.destroy (http.js:458:15)
<     at ServerResponse.onclose (stream.js:74:50)
<     at ServerResponse.emit (events.js:126:20)
<     at Stream.onServerResponseClose (http.js:987:44)
<     at Stream.emit (events.js:126:20)
<     at /mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/node_modules/spdy/lib/spdy/server.js:520:10
<     at process._tickCallback (node.js:244:9)
< ----------------------------------------
<     at EventEmitter.on
<     at ServerResponse.pipe (stream.js:58:12)
<     at handlePlain (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/lib/server.js:77:9)
<     at /mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/lib/server.js:114:58
<     at [object Object].handleRequest (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/lib/server.js:144:7)
<     at [object Object].emit (events.js:99:17)
<     at Connection.onrequest (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/node_modules/spdy/lib/spdy/server.js:96:14)
< ----------------------------------------
<     at EventEmitter.on
<     at new <anonymous> (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/lib/server.js:152:8)
<     at new <anonymous> (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/lib/server.js:158:10)
<     at Object.<anonymous> (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/bin/spdyproxy:85:13)
<     at Module._compile (module.js:449:26)
<     at Object..js (module.js:467:10)
<     at Module.load (module.js:356:32)
<     at Function._load (module.js:312:12)
<     at Object._onTimeout (module.js:492:10)
< Uncaught undefined
< Uncaught undefined
< /mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/node_modules/long-stack-traces/lib/long-stack-traces.js:80
<                     throw ""; // TODO: throw the original error, or undefined?
<          
<            ^
program terminated

HTTP not working: Error 332 (net::ERR_SYN_REPLY_NOT_RECEIVED)

Hi,

when using the latest code from master proxying http requests are not working anymore for me. SSL/https sites run fine.

$ node -v
v0.10.8

Here is the relevant output while trying to access http://www.dnsleaktest.com/:

// Chrome error:
Error 332 (net::ERR_SYN_REPLY_NOT_RECEIVED): Unknown error.
$  ./bin/spdyproxy -k keys/localhost/mykey.pem -c keys/localhost/mycert.pem -p 44300 -U user -P pass -v

127.0.0.1:34884 - GET - stream ID: 25 - priority: 2
GET /
 > host: www.dnsleaktest.com
 > path: /
 > accept: */*
 > accept-charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
 > accept-encoding: gzip,deflate,sdch
 > accept-language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
 > user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31
chrome://net-internals/#events


99123: URL_REQUEST
http://www.dnsleaktest.com/
Start Time: 2013-05-27 16:37:52.284

t=1369665472284 [st=0] +REQUEST_ALIVE  [dt=4]
t=1369665472284 [st=0]    URL_REQUEST_BLOCKED_ON_DELEGATE  [dt=1]
                          --> delegate = "Ghostery-Erweiterung"
t=1369665472285 [st=1]   +URL_REQUEST_START_JOB  [dt=2]
                          --> load_flags = 67174528 (ENABLE_LOAD_TIMING | MAYBE_USER_GESTURE | VERIFY_EV_CERT)
                          --> method = "GET"
                          --> priority = 2
                          --> url = "http://www.dnsleaktest.com/"
t=1369665472285 [st=1]      HTTP_CACHE_GET_BACKEND  [dt=0]
t=1369665472285 [st=1]      HTTP_CACHE_OPEN_ENTRY  [dt=0]
                            --> net_error = -2 (ERR_FAILED)
t=1369665472285 [st=1]      HTTP_CACHE_CREATE_ENTRY  [dt=0]
t=1369665472285 [st=1]      HTTP_CACHE_ADD_TO_ENTRY  [dt=0]
t=1369665472285 [st=1]     +HTTP_STREAM_REQUEST  [dt=0]
t=1369665472285 [st=1]        HTTP_STREAM_REQUEST_BOUND_TO_JOB
                              --> source_dependency = 99126 (HTTP_STREAM_JOB)
t=1369665472285 [st=1]     -HTTP_STREAM_REQUEST
t=1369665472285 [st=1]     +HTTP_TRANSACTION_SEND_REQUEST  [dt=0]
t=1369665472285 [st=1]        HTTP_TRANSACTION_SPDY_SEND_REQUEST_HEADERS
                              --> :host: www.dnsleaktest.com
                                  :method: GET
                                  :path: /
                                  :scheme: http
                                  :version: HTTP/1.1
                                  accept: */*
                                  accept-charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
                                  accept-encoding: gzip,deflate,sdch
                                  accept-language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
                                  user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31
t=1369665472285 [st=1]     -HTTP_TRANSACTION_SEND_REQUEST
t=1369665472285 [st=1]     +HTTP_TRANSACTION_READ_HEADERS  [dt=2]
t=1369665472287 [st=3]        SPDY_STREAM_ERROR
                              --> description = "Didn't receive a response."
                              --> status = -332
                              --> stream_id = 33
t=1369665472287 [st=3]     -HTTP_TRANSACTION_READ_HEADERS
                            --> net_error = -332 (ERR_SYN_REPLY_NOT_RECEIVED)
t=1369665472287 [st=3]   -URL_REQUEST_START_JOB
                          --> net_error = -332 (ERR_SYN_REPLY_NOT_RECEIVED)
t=1369665472288 [st=4] -REQUEST_ALIVE
                        --> net_error = -332 (ERR_SYN_REPLY_NOT_RECEIVED)
99126: HTTP_STREAM_JOB
http://www.dnsleaktest.com/
Start Time: 2013-05-27 16:37:52.285

t=1369665472285 [st=0] +HTTP_STREAM_JOB  [dt=0]
                        --> original_url = "http://www.dnsleaktest.com/"
                        --> url = "http://www.dnsleaktest.com/"
t=1369665472285 [st=0]   +PROXY_SERVICE  [dt=0]
t=1369665472285 [st=0]      PROXY_SERVICE_RESOLVED_PROXY_LIST
                            --> pac_string = "HTTPS localhost:44300"
t=1369665472285 [st=0]   -PROXY_SERVICE
t=1369665472285 [st=0]    SPDY_SESSION_POOL_FOUND_EXISTING_SESSION
                          --> source_dependency = 98852 (SPDY_SESSION)
t=1369665472285 [st=0]    HTTP_STREAM_JOB_BOUND_TO_REQUEST
                          --> source_dependency = 99123 (URL_REQUEST)
t=1369665472285 [st=0] -HTTP_STREAM_JOB

I tried different node versions (0.8 / 0.12) with no luck as well.

Anyone else having these issues?
Thanks.

update package on npmjs.org suggestion

npm install spdyproxy will install an outdated v0.2.3 , I think that was published last year. The outdated version did not work because dependency spdy module renamed .lock method to _lock, I checked code history and find out the .lock issue was already fixed in commit c26934a by Aveline Swan, maybe publish the update to npmjs.org may keep new install more easier.

call to _framer.replyFrame fails

In server.js, function synReply, a line of code needs changing to:

      this._spdyState.framer.replyFrame(

I guess the spdy library got its internals rearranged.

also, you should probably make the try{} catch log something... Otherwise you get really weird errors when the lock gets stuck locked and it's hard to debug...

Cannot read property 'connection' of undefined

Looks like these four lines are causing problems under some circumstances. It happens rarely but @ym and I can confirm that it does happen once in a while. I will update this issue when I find a way to reproduce.

console.log("%s:%s".yellow + " - %s - " + "stream ID: " + "%s".yellow,
  socket.connection ? socket.connection.socket.remoteAddress : socket.socket.remoteAddress,
  socket.connection ? socket.connection.socket.remotePort : socket.socket.remotePort,
  req.method, res.streamID || socket.streamID
);

Stack trace:

< Uncaught TypeError: Cannot read property 'connection' of undefined
<     at [object Object].handleRequest (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/lib/server.js:110:13)
<     at [object Object].emit (events.js:99:17)
<     at Connection.onrequest (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/node_modules/spdy/lib/spdy/server.js:96:14)
<     at Connection.emit (events.js:99:17)
<     at HTTPParser.onIncoming (http.js:1889:12)
<     at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:111:23)
<     at Stream.ondata (http.js:1786:22)
<     at Stream.<anonymous> (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/node_modules/spdy/lib/spdy/server.js:441:27)
< ----------------------------------------
<     at EventEmitter.on
<     at new <anonymous> (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/lib/server.js:154:8)
<     at new <anonymous> (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/lib/server.js:160:10)
<     at Object.<anonymous> (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/bin/spdyproxy:86:13)
<     at Module._compile (module.js:449:26)
<     at Object..js (module.js:467:10)
<     at Module.load (module.js:356:32)
<     at Function._load (module.js:312:12)
<     at Object._onTimeout (module.js:492:10)
< Uncaught undefined
< Uncaught undefined
< Uncaught undefined
< /mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/node_modules/long-stack-traces/lib/long-stack-traces.js:80
<                     throw ""; // TODO: throw the original error, or undefined?
<                     ^
program terminated

backpressure is broken

Recently I found that node eat a huge amount of memory in my production servers. After a brief test by downloading a 100M binary file I found this:

chart2 php

This is very clear that backpressure is broken. I have no idea why it happens as stream.pipe() should already handled that. It looks like the underlying node-spdy's problem. I.e. the 'drain' event of underlying socket was not propagate to the response stream.

Issue #24 may be related to this.

@indutny any ideas?

Allow usage from a module

It would be great if this library wouldn't require to be run using bin/spdyproxy. The most important issue is the heavy usage of colors methods inside lib/server.js. colors isn't required by the file, which leads to unexpected bugs.

Plus, the API could be properly documented.

Feature requestion: options for sandbox

This is a common optional feature among proxies and VPNs: after initialization is done, the process switches to a different UID and GID, often of nobody and nogroup, effectively living in a sandbox. This ensures that any bugs and security vulnerabilities in the program can only do very little damage.

Enhancement: option to serve PAC file on https

It would be a lovely enhancement were node-spdyproxy able to serve a PAC file. Otherwise serving the PAC file requires running a separate HTTP/HTTPS server to be fed a PAC file and running.

Error: TypeError: Cannot read property 'remoteAddress' of undefined

Seems this error is appearing when running on Alpine Linux but on Debian it works. Here is the Dockerfile to reproduce:

FROM alpine:3.4
RUN apk add --no-cache ca-certificates nodejs && npm install -g spdyproxy
EXPOSE 44300
CMD ["spdyproxy", "--key", "/mnt/tls.key", "--cert", "/mnt/tls.crt"]

Then build and run it:

$ docker build -t spdyproxy .
$ docker run --rm -it -p 44300:44300 -v /path/to/tls:/mnt:ro spdyproxy

Then the log shows an error during usage:

Error: TypeError: Cannot read property 'remoteAddress' of undefined

running "npm install -g spdyproxy" encounter errors,how to fix it?

root@133-130-58-26:# npm install -g spdyproxy
npm http GET https://registry.npmjs.org/spdyproxy
npm http GET https://registry.npmjs.org/spdyproxy
npm http GET https://registry.npmjs.org/spdyproxy
npm ERR! Error: SSL Error: CERT_UNTRUSTED
npm ERR! at ClientRequest. (/usr/local/lib/node_modules/npm/node_modules/request/main.js:440:26)
npm ERR! at ClientRequest.g (events.js:185:14)
npm ERR! at ClientRequest.EventEmitter.emit (events.js:88:17)
npm ERR! at HTTPParser.parserOnIncomingClient (http.js:1445:7)
npm ERR! at HTTPParser.parserOnHeadersComplete as onHeadersComplete
npm ERR! at CleartextStream.socketOnData (http.js:1356:20)
npm ERR! at CleartextStream.CryptoStream._push (tls.js:396:27)
npm ERR! at SecurePair.cycle (tls.js:750:20)
npm ERR! at EncryptedStream.CryptoStream.write (tls.js:131:13)
npm ERR! at Socket.ondata (stream.js:38:26)
npm ERR! [Error: SSL Error: CERT_UNTRUSTED]
npm ERR! You may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! [email protected]
npm ERR! System Linux 3.2.0-4-amd64
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "spdyproxy"
npm ERR! node -v v0.8.2
npm ERR! npm -v 1.1.36
npm ERR! message SSL Error: CERT_UNTRUSTED
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /root/npm-debug.log
npm ERR! not ok code 0
root@133-130-58-26:
#

tks a lot

Memory leak with v0.10.15, Segfaults with v0.11.5

Hi,

I have some issue with node-spdyproxy under a bit of load (~130 concurrent unique connections).

I'm using the latest node-spdyproxy 0.2.5

When using nodejs v0.10.15 (stable) I'll have a reproducible memory leak, forcing me to restart the process from time to time.

Using nodejs v0.11.5 (unstable) dmesg reports segfaults after some time that add up to the point where the process stops functioning:

[2013-08-09 18:30:00] node[952301]: segfault at 0 ip 00000000006f81cb sp 00007fff28053460 error 4 in node[400000+8b0000]
[2013-08-09 18:30:00] node[952285] general protection ip:6f81dc sp:7fff8fe761a0 error:0 in node[400000+8b0000]
[2013-08-09 18:30:00] node[952282]: segfault at 0 ip 00000000006f81cb sp 00007fff1a6ecbc0 error 4 in node[400000+8b0000]
[2013-08-09 18:30:00] node[952309] general protection ip:6000ff sp:7fffe5afac20 error:0 in node[400000+8b0000]
[2013-08-09 18:30:01] node[952281]: segfault at 0 ip 00000000006f81cb sp 00007fff896a4dd0 error 4 in node[400000+8b0000]
[2013-08-09 18:31:08] IPv6 addrconf: prefix with wrong length 48
[2013-08-09 18:33:54] IPv6 addrconf: prefix with wrong length 48
[2013-08-09 18:37:27] node[952292]: segfault at 11 ip 00000000006000ff sp 00007fffe877eb90 error 4 in node[400000+8b0000]
[2013-08-09 18:37:31] node[955445] general protection ip:6000ff sp:7ffffacb1520 error:0 in node[400000+8b0000]
[2013-08-09 18:38:23] node[952291] general protection ip:6f81dc sp:7fff63141eb0 error:0 in node[400000+8b0000]
[2013-08-09 18:39:16] node[955405] general protection ip:6000ff sp:7fffc0be7730 error:0 in node[400000+8b0000]
[2013-08-09 18:40:41] node[952401]: segfault at 0 ip 00000000006f81cb sp 00007fff0695f720 error 4 in node[400000+8b0000]
[2013-08-09 18:42:13] node[955808] general protection ip:6000ff sp:7fff9d1f9fc0 error:0 in node[400000+8b0000]
[2013-08-09 18:48:51] node[956618]: segfault at 0 ip 00000000006f81cb sp 00007fff2d753870 error 4 in node[400000+8b0000]
[2013-08-09 18:48:52] node[956624]: segfault at 0 ip 00000000006f81cb sp 00007fffc5d6cc90 error 4 in node[400000+8b0000]
[2013-08-09 18:48:58] node[956648]: segfault at 0 ip 00000000006f81cb sp 00007fff43552660 error 4 in node[400000+8b0000]
[2013-08-09 18:56:02] node[957811]: segfault at d ip 00000000006000ff sp 00007fffa63bc870 error 4 in node[400000+8b0000]
[2013-08-09 18:56:23] node[957855] general protection ip:6000ff sp:7fffae411170 error:0 in node[400000+8b0000]
[2013-08-09 18:57:19] node[957809]: segfault at 0 ip 00000000006f81cb sp 00007fff98efdc20 error 4 in node[400000+8b0000]
[2013-08-09 19:18:03] node[958791] general protection ip:6000ff sp:7fff1ccfd150 error:0 in node[400000+8b0000]
[2013-08-09 19:18:07] node[958743]: segfault at 48 ip 00000000006f81dc sp 00007ffff1f02c10 error 4 in node[400000+8b0000]
[2013-08-09 19:18:17] node[958744] general protection ip:6000ff sp:7fff83f81990 error:0 in node[400000+8b0000]
[2013-08-09 19:24:47] node[959555]: segfault at 11 ip 00000000006000ff sp 00007fff13b65920 error 4 in node[400000+8b0000]
[2013-08-09 19:25:03] node[958797]: segfault at 11 ip 00000000006000ff sp 00007fff973262e0 error 4 in node[400000+8b0000]
[2013-08-09 19:30:25] node[958745] general protection ip:6000ff sp:7fff4cc544d0 error:0 in node[400000+8b0000]
[2013-08-09 19:35:59] node[958758]: segfault at 11 ip 00000000006000ff sp 00007fff6b6fec00 error 4 in node[400000+8b0000]
[2013-08-09 19:35:59] node[959804]: segfault at 11 ip 00000000006000ff sp 00007ffffccfd380 error 4 in node[400000+8b0000]
[2013-08-09 19:36:00] node[958774]: segfault at 0 ip 00000000006f81cb sp 00007fffe9641b10 error 4 in node[400000+8b0000]

I'm also using node-spdyproxy in conjunction with naught as a cluster module and for zero-downtime deploys.

Any ideas how to investigate these issues further?

  • I tried node-spdy dependencies ranging from v1.8.9 to v1.10.1 with no luck.
  • I raised the ulimit on the server and tweaked sysctl
  • Tweaking v8 with --nouse-idle-notification --max-new-space-size=2048 --max-old-space-size=14336 showed no difference.

Any help is greatly appreciated.

Thanks.

about radius!

I use radius ,but the session of Simultaneous-Use is not effective!How can I do?Thank you!

bind to interface

Hello,

Running spdyproxy daemon with the option "--localAddress" doesn't work. It will bind to 0.0.0.0.
I've tried with "--localAddress lo", "--localAddress eth1:1" (virtual).

Tunnel error: Error: getaddrinfo ESRCH

Hello,
I deploy the proxy to the VPS, and everything is OK. But when the connections rise, there are tons of "Tunnel error: Error: getaddrinfo ESRCH" in the log.
...
Thu Mar 19 2015 09:28:16 GMT+0000 (UTC) Tunnel error: Error: connect EMFILE
Thu Mar 19 2015 09:28:16 GMT+0000 (UTC) Tunnel error: Error: getaddrinfo ESRCH
Thu Mar 19 2015 09:28:16 GMT+0000 (UTC) Tunnel error: Error: getaddrinfo ESRCH
Thu Mar 19 2015 09:28:16 GMT+0000 (UTC) Tunnel error: Error: getaddrinfo ESRCH
Thu Mar 19 2015 09:28:20 GMT+0000 (UTC) Tunnel error: Error: getaddrinfo ESRCH
Thu Mar 19 2015 09:28:20 GMT+0000 (UTC) Tunnel error: Error: getaddrinfo ESRCH
Thu Mar 19 2015 09:28:21 GMT+0000 (UTC) Tunnel error: Error: getaddrinfo ESRCH
...
I change the VPS max open file limit

ulimit -a

core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 14873
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65535
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 14873
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

But it doesn't work.

Probably memory leak while watching YouTube 720P video

When using the lasted vision of spdyproxy (0.24, node-spdy 1.5))to watch YouTube 720P video, the "node"process terminated immediately. But watching the 480P is very smooth and fast.
The log is:

[33m124.205.203.134:57910�[39m - GET - stream ID: �[33m67�[39m
�[32mGET�[39m �[33m/sb/DconsfGsXyA/storyboard3_L1/M0.jpg?sigh=_ob8J3I8ej3ZYJ87Z-uXTwdmkI8�[39m
�[90m > �[39m�[36mhost�[39m: i1.ytimg.com
�[90m > �[39m�[36mpath�[39m: /sb/DconsfGsXyA/storyboard3_L1/M0.jpg?sigh=_ob8J3I8ej3ZYJ87Z-uXTwdmkI8
�[90m > �[39m�[36maccept�[39m: */*
�[90m > �[39m�[36maccept-charset�[39m: ISO-8859-1,utf-8;q=0.7,*;q=0.3
�[90m > �[39m�[36maccept-encoding�[39m: gzip,deflate,sdch
�[90m > �[39m�[36maccept-language�[39m: en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4
�[90m > �[39m�[36mdnt�[39m: 1
�[90m > �[39m�[36mreferer�[39m: http://www.youtube.com/watch?v=DconsfGsXyA
�[90m > �[39m�[36muser-agent�[39m: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

And the proxy server's node process memory usage had burst:

�[7m  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            �(B�[m�[39;49m�[K
�(B�[m 3140 root      15   0 58208  24m 6128 S  2.0  9.5   0:00.80 node               �(B�[m�[39;49m
�(B�[m 3140 root      15   0 58208  24m 6128 S  0.0  9.5   0:00.80 node               �(B�[m�[39;49m
�(B�[m 3140 root      16   0 58208  24m 6128 S  4.0  9.6   0:00.84 node               �(B�[m�[39;49m
�(B�[m 3140 root      15   0  104m  67m 6132 S 67.5 26.4   0:01.52 node               �(B�[m�[39;49m
�(B�[m 3140 root      16   0  122m  84m 6132 R 48.0 33.1   0:02.00 node               �(B�[m�[39;49m
�(B�[m 3140 root      15   0  158m 119m 6132 S 41.9 46.8   0:02.42 node               �(B�[m�[39;49m
�(B�[m 3140 root      15   0  197m 154m 6132 S 44.9 60.4   0:02.87 node               �(B�[m�[39;49m
�(B�[m 3140 root      15   0  233m 189m 6132 S 49.0 73.9   0:03.36 node               �(B�[m�[39;49m

Radius user group and traffic limitation

For some reason I don't want all users in my radius system to access this service. So if there's some way to deny user's access who isn't in the special group that I designated?
And is there some way to limit user's data traffic?

crashing (possible memory leak)

After using the proxy for some hours, it randomly stops processing new connections. Going through the log, I found errors like the following:

(node) warning: possible EventEmitter memory leak detected. 101 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at ServerResponse.addListener (events.js:160:15)
    at ServerResponse.once (events.js:185:8)
    at IncomingMessage.Readable.pipe (_stream_readable.js:538:8)
    at ClientRequest.<anonymous> (/usr/local/lib/node_modules/spdyproxy/lib/server.js:80:12)
    at ClientRequest.g (events.js:180:16)
    at ClientRequest.emit (events.js:95:17)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1688:21)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
    at Socket.socketOnData [as ondata] (http.js:1583:20)
    at TCP.onread (net.js:527:27)

any tips? thanks in advance

TypeError [ERR_INVALID_ARG_TYPE]: The "superCtor" argument must be of type Function. Received type undefined?

hi.

root@wh:~# spdyproxy -k /root/private.key -c /root/public.crt -p 344 -U myusername -P mypassword

the command shows:
util.js:281
throw new ERR_INVALID_ARG_TYPE('superCtor', 'Function', superCtor);
^

TypeError [ERR_INVALID_ARG_TYPE]: The "superCtor" argument must be of type Function. Received type undefined
at Object.inherits (util.js:281:11)
at Object. (/root/node-v10.14.1-linux-x64/lib/node_modules/spdyproxy/node_modules/spdy/lib/spdy/connection.js:84:6)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object. (/root/node-v10.14.1-linux-x64/lib/node_modules/spdyproxy/node_modules/spdy/lib/spdy.js:20:19)
root@wh:~#

how to fix it?
thank u for ur reply!!

spdyproxy runs Cannot Connect to spdyproxy

Hi im sorry to asking this here but i successfully install spdyproxy in my virtual machine in local system and create selfsign certificate for testing propose but each time i start spdyproxy my server runs and it says spdyproxy start but i cannot connect to it using chrome extention or launching chrome with pac file . it cannot open any site.

Proxy freeze when downloading[Qos support]

When downloading a file or viewing a YouTube HD video, it will be impossible to open a web page as all bandwidth is consumed by the big stream.

Although the single SPDY connection is framed, but somehow the proxy server didn't handle multiple connections correctly.

Memory Problems

After the proxy runs for a while, the baseline memory usage is definitely going in an upward trend. The usage also fluctuates a lot. For example, if I play 2 youtube HD video together, the memory consumption can go more than 125 MB (25% on a 512MB VPS).

I am playing with all the profiling methods that I found in google. If you have any quick hunches or insights, it will be very helpful. Thanks.

How to add multiple user?

# pass in -U and -P flags to spdyproxy to set the Basic-Auth username and password
$> spdyproxy -k keys/mykey.pem -c keys/mycert.pem -p 44300 -U user -P pass

It seems only support one user, how to add multiple?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.