Created
November 28, 2015 14:30
-
-
Save ramsunvtech/a0f1b8107449fb2f0728 to your computer and use it in GitHub Desktop.
Vhost in NodeJS
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'), | |
serveStatic = require('serve-static'), | |
vhost = require('vhost') | |
var mailapp = connect() | |
// add middlewares to mailapp for mail.example.com | |
// create app to serve static files on subdomain | |
var staticapp = connect() | |
staticapp.use(serveStatic('public')) | |
// create main app | |
var app = connect() | |
// add vhost routing to main app for mail | |
app.use(vhost('mail.example.com', staticapp)); | |
var PORT = 80; | |
app.listen(PORT) | |
console.log('app listening to ', PORT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment