Created
August 1, 2014 17:31
-
-
Save kevrom/863b625d4728b317605f to your computer and use it in GitHub Desktop.
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
// NGINX config | |
upstream node-catfacts { | |
server localhost:8040; | |
} | |
server { | |
listen 80; | |
server_name catfacts.kevrom.com; | |
access_log /home/kevrom/projects/node-catfacts/logs/nginx/access.log; | |
error_log /home/kevrom/projects/node-catfacts/logs/nginx/error.log; | |
location /js { | |
alias /home/kevrom/projects/node-catfacts/dist/js; | |
} | |
location /img { | |
alias /home/kevrom/projects/node-catfacts/dist/img; | |
} | |
location /css { | |
alias /home/kevrom/projects/node-catfacts/dist/css; | |
} | |
location /lib { | |
alias /home/kevrom/projects/node-catfacts/dist/lib; | |
} | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_set_header X-NginX-Proxy true; | |
proxy_pass http://node-catfacts/; | |
proxy_redirect off; | |
} | |
} | |
// server.js | |
'use strict'; | |
var express = require('express'), | |
http = require('http'), | |
path = require('path'), | |
RedisStore = require('connect-redis')(express), | |
simpledb = require('mongoose-simpledb'), | |
flash = require('connect-flash'); | |
var app = express(); | |
simpledb.init({ | |
connectionString: 'mongodb://localhost/node-catfacts', | |
modelsDir: path.join(__dirname, 'models') | |
}, function(err, db) { | |
if (err) { console.log(err); } | |
}); | |
app.set('port', process.env.PORT || 8040); | |
app.set('views', __dirname + '/views'); | |
app.set('view engine', 'jade'); | |
app.locals.pretty = true; | |
app.use(express.logger('dev')); | |
app.use(express.json()); | |
app.use(express.urlencoded()); | |
app.use(express.cookieParser()); | |
app.use(express.session({ | |
secret: 'thisisnttherightsecret', | |
store: new RedisStore(), | |
cookie: { secure: false, maxAge:86400000 } | |
})); | |
app.use(express.methodOverride()); | |
app.use(flash()); | |
app.use(app.router); | |
app.use(function(err, req, res, next){ | |
console.error(err.stack); | |
res.send(500, 'Something broke!'); | |
}); | |
app.configure('development', function() { | |
app.use(express.errorHandler()); | |
app.use(express.static(path.resolve(__dirname, '../dist'))); | |
}); | |
// URLs | |
require('./routes')(app); | |
http.createServer(app).listen(app.get('port'), function(){ | |
console.log('Express server listening on port ' + app.get('port')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment