A really simple but (hopefully) useful HTTP redirector which can be run as a daemon
tdp-http-redirector is a really simple HTTP redirector module (primarily intended as a standalone application) which can be daemonised or run as-is in "normal" mode (really just for testing). Purposefully low on requirements and dependencies, small (and thus hopefully at least ultimately fast) it is also easy to configure, using only standard JSON configuration files.
This is currently very much alpha in status, only manual testing has been performed so far.
Installation can be achieved easily via npm as follows:
$ npm install tdp-http-redirector
Please note that tdp-http-redirector is really only designed to run on POSIX-style (perhaps with some tweaking) it may run on Windows (though you should note that tdp-http-redirector) is case-sensitive (Windows for the most part is not).
Ensure you have nodejs and npm installed, cd to your desirted install location then install the NPM module as shown above.
Now open config/options.js and config/redirectRules.js. Configuration should be simple and self-explanatory, each file contains comments and a working config which aside form the redirect rules may well be fine for most uses.
The following is a guide to content of each config file:
This file contains the main HTTP redirector options e.g. number of worker processes (daemonised mode), IP and port to bind to and HTTP headers to return for matched and unmatched rules.
This file contains only redirector rules which are a simple JSON obj in the form:
The daemon is configured in daemonHttpRedirector.js. You should not need to amend this however options can be found in the documentation for daemonize2
To start in daemonised mode, cd to your install location and type:
$ node daemon-tdp-http-redirector.js start
You can stop the daemon similarly:
$ node daemon-tdp-http-redirector.js stop
And restarting is achieved by:
$ node daemon-tdp-http-redirector.js restart
Finally, you can check the status (and get the mast process PID) by doing:
$ node daemon-tdp-http-redirector.js status
To use TDP HTTP Redirector in "normal" mode, just run:
$ node tdp-http-redirector.js
To stop the process, just hit ctrl+c
(The MIT License)
Copyright (c) 2012 Neil Craig (theDotProduct)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.