Created
December 15, 2013 08:02
-
-
Save marcelofernandez/7970225 to your computer and use it in GitHub Desktop.
node-spdy static server with Virtualhosts example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var connect = require('connect'), | |
fs = require('fs'), | |
spdy = require('spdy'), | |
web_directory = '/var/www/', | |
port = process.argv[2] || '8443'; | |
var options = { | |
// plain - if defined, server will ignore NPN and ALPN data and choose whether | |
// to use spdy or plain http by looking at first data packet. | |
plain: (port == '80'), | |
// ssl - if false and options.plain is true, http.Server will be used | |
ssl: (port != '80'), | |
key: fs.readFileSync('keys/selfsigned.crt'), | |
cert: fs.readFileSync('keys/selfsigned.crt'), | |
// To allow wireshark to decrypt this traffic, set this cipher suite: | |
// ciphers: 'DES-CBC3-SHA', | |
// We'll serve 200 streams per spdy session | |
maxStreams: 200, | |
}; | |
var app = connect() | |
//.use(connect.logger('dev')) // Use only for debugging | |
.use(connect.vhost('www.amazon.com', connect.static(web_directory + 'amazon/'))) | |
.use(connect.vhost('www.bing.com', connect.static(web_directory + 'bing/'))) | |
.use(connect.vhost('login.yahoo.com', connect.static(web_directory + 'yahoomail/'))) | |
.use(connect.vhost('www.worldflags.com', connect.static(web_directory + 'worldflags/'))); | |
var server = spdy.createServer(options, app); | |
server.listen(port, function() { | |
var addr = this.address(); | |
console.log('Server is listening on %s:%d', addr.address, addr.port); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment