Skip to content

Instantly share code, notes, and snippets.

@ssoper
Created June 19, 2012 21:43
Show Gist options
  • Save ssoper/2956712 to your computer and use it in GitHub Desktop.
Save ssoper/2956712 to your computer and use it in GitHub Desktop.
Run Kue alongside another Express server using a different path
// Assumes you want to run a kue server on port 3001 with the path '/kue'.
// Use a proxy like nginx to send the requests to the appropriate URL.
require lodash = require('lodash'),
kue = require('kue');
// Prepend the Kue routes with '/kue'
lodash.each(['get', 'put', 'delete'], function(verb) {
lodash.each(kue.app.routes.routes[verb], function(route, index, routes) {
routes[index].path = '/kue' + route.path;
routes[index].regexp = new RegExp(route.regexp.source.replace(/\^\\/, '^\\/kue\\'));
});
});
// The last handler should be for the /public files, pop it off and add a new one which mounts them at '/kue'
var handler = kue.app.stack.pop();
kue.app.stack.push({ route: '/kue', handle: handler.handle });
kue.app.listen(3001);
// Sample nginx.conf
// upstream kue {
// server 127.0.0.1:3001;
// }
// server {
// location /kue/ {
// proxy_pass http://kue/;
// proxy_redirect off;
// }
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment