cdn-server
This is a basic cdn server engine
How does it work
First install it:
npm install --save cdn-server
It uses the redis-url-cache node library to store URLs in a redis data store, and bunyan for JSON logging.
It runs on a node.js http server
The config file is straight forward.
Config JSON
The JSON format is:
instanceName See Instances
RedisUrlCache.RedisStorageConfig See Redis Config
RedisUrlCache.CacheRules See Cache Rules
Note Regexes inside cacheRules must be valid.
Usage
var CacheServer = ;var bunyan = ; var config = defaultDomain: 'http://127.0.0.1:3000/' port: 3030 instanceName: 'CACHE' redisConfig: host: '127.0.0.1' port: 6379 cacheRules: default: 'always' always: never: maxAge: var logger = bunyan; var server = config logger; serverstart { iferr throw err; console;};
Then you can CURL:
curl --header "referer: http://whatever.com" http://127.0.0.1:3030/get?url=http://www.google.com
The
referer
header is mandatory
Whats wrong with it?
It doesn't supports CORS (yet), although the fix is trivial
This is just a server, if you query http://127.0.0.1:3030/get?url=http://www.google.com&referer=http://whatever.com
, inside your browser, you will of course get the correct HTML, but the browser will call the wrong relative URLs.