This is a simple redis proxy intented to server a jsonp access or an socket-io real time proxy.
Check the code before using it on a production environment or at least don't deploy it outside of the DMZ nor having the redis any kind of confidencial information.
git clone https://github.com/ffis/redisproxy.git
cd redisproxy
npm install
Duplicate config-example.json and rename to config.json configure redis connection parameters.
Redisproxy is based on different plugins, you may need to activate in order to obtain the desired behavior. The in-built plugins are:
- api: Adds and
/api
endpoint that lists what keys are available on redis server. - compression: Adds compression to all HTTP requests and responses.
- cors: Enables CORS to HTTP requests.*
- jwt: Adds authentication verification via Authorization header. It expects that starts with 'Bearer ' string.*
- notify: Sends a notification via http to an HTTP/s server that the request has been made.
- realtimeproxy: Proxies messages from a redis channel to sockets connected via socket.io.
- redisproxy: Exposes redis content as readonly using GET method.
- static: Exposes a file directory.*
*: You may need to configure this plugin in order to work.
Note:
- some plugins like static can be selected more than once.
- some plugins should be used with caution and always with an authentication/authorization service like jwt.
Suppose the Redis server is configured on host 127.0.0.1, then run this script on terminal:
wget https://github.com/crypt1d/redi.sh/raw/master/redi.sh
echo "this is a variable" | bash redi.sh -s testvar -H 127.0.0.1
bash redi.sh -g testvar -H 127.0.0.1
If you can read "this is a variable" then everything is ok.
npm start
npm run coverage