A very simple web server providing an HTTP interface to Redis. It uses [hiredis](https://github.com/antirez/hiredis), [jansson](https://github.com/akheron/jansson), [libevent](https://monkey.org/~provos/libevent/), and [http-parser](https://github.com/ry/http-parser/).
A very simple web server providing an HTTP interface to Redis. It uses [hiredis](https://github.com/antirez/hiredis), [jansson](https://github.com/akheron/jansson), [libevent](https://monkey.org/~provos/libevent/), and [http-parser](https://github.com/ry/http-parser/).
@ -82,10 +82,10 @@ ECR images are not signed at this time, but they use the exact same hash as the
Clone the repository and open a terminal in the webdis directory, then run:
Clone the repository and open a terminal in the webdis directory, then run:
```sh
```sh
$ docker build -t webdis .
$ docker build -t webdis:custom .
[...]
[...]
$ docker run --name webdis-test --rm -d -p 7379:7379 webdis
$ docker run --name webdis-test --rm -d -p 7379:7379 webdis:custom
* `GET` and `POST` are supported, as well as `PUT` for file uploads.
* `GET` and `POST` are supported, as well as `PUT` for file uploads (see example of `PUT` usage [here](#file-upload)).
* JSON output by default, optional JSONP parameter (`?jsonp=myFunction` or `?callback=myFunction`).
* JSON output by default, optional JSONP parameter (`?jsonp=myFunction` or `?callback=myFunction`).
* Raw Redis 2.0 protocol output with `.raw` suffix
* Raw Redis 2.0 protocol output with `.raw` suffix.
* MessagePack output with `.msg` suffix
* MessagePack output with `.msg` suffix.
* HTTP 1.1 pipelining (70,000 http requests per second on a desktop Linux machine.)
* HTTP 1.1 pipelining (70,000 http requests per second on a desktop Linux machine.)
* Multi-threaded server, configurable number of worker threads.
* Multi-threaded server, configurable number of worker threads.
* WebSocket support (Currently using the “hixie-76” specification).
* [WebSocket support](#websockets) (Currently using the specification from [RFC 6455](https://datatracker.ietf.org/doc/html/rfc6455)).
* Connects to Redis using a TCP or UNIX socket.
* Connects to Redis using a TCP or UNIX socket.
* Restricted commands by IP range (CIDR subnet + mask) or HTTP Basic Auth, returning 403 errors.
* Restricted commands by IP range (CIDR subnet + mask) or HTTP Basic Auth, returning 403 errors.
* Support for Redis authentication in the config file: set `redis_auth` to a single string to use a password value, or to an array of two strings to use username+password auth ([new in Redis 6.0](https://redis.io/commands/auth)).
* Support for Redis authentication in the config file: set `redis_auth` to a single string to use a password value, or to an array of two strings to use username+password auth ([new in Redis 6.0](https://redis.io/commands/auth)).
@ -119,11 +119,11 @@ f0a2763fd456
* Set `"log_fsync": N` where `N` is a number to call `fsync` every `N` milliseconds.
* Set `"log_fsync": N` where `N` is a number to call `fsync` every `N` milliseconds.
* Set `"log_fsync": "all"` (very slow) to persist the log file to its storage device on each log message.
* Set `"log_fsync": "all"` (very slow) to persist the log file to its storage device on each log message.
* [HTTP Basic Auth](https://en.wikipedia.org/wiki/Basic_access_authentication) in the format of "user:password".
* [HTTP Basic Auth](https://en.wikipedia.org/wiki/Basic_access_authentication) in the format of "user:password".
Each ACL contains two lists of commands, `enabled` and `disabled`. All commands being enabled by default, it is up to the administrator to disable or re-enable them on a per-profile basis.
Each ACL contains two lists of commands, `enabled` and `disabled`. All commands being enabled by default, it is up to the administrator to disable or re-enable them on a per-profile basis.
Web Sockets are supported with the following formats, selected by the connection URL:
**Important:** WebSocket support is currently _disabled by default_. To enable WebSocket support, set the key named `"websockets"` to value `true` in `webdis.json`, e.g.
```json
{
"daemonize": false,
"websockets": true,
}
```
(start and end of file omitted).
WebSockets are supported with the following formats, selected by the connection URL:
* JSON (on `/` or `/.json`)
* JSON (on `/` or `/.json`)
* Raw Redis wire protocol (on `/.raw`)
* Raw Redis wire protocol (on `/.raw`)
@ -379,15 +391,14 @@ Web Sockets are supported with the following formats, selected by the connection
```javascript
```javascript
function testJSON() {
function testJSON() {
var jsonSocket = new WebSocket("ws://127.0.0.1:7379/.json");
var jsonSocket = new WebSocket("ws://127.0.0.1:7379/.json");
The Webdis repository contains a demo web page with JavaScript code that can be used to test WebSocket support.
In a terminal, check out Webdis, build it, and configure it with WebSocket support:
```shell
$ cd ~/src/webdis
$ make
$ vim webdis.json # (edit the file to add "websockets": true)
$ grep websockets webdis.json
"websockets": true,
$ ./webdis
```
Then go to the `tests/` directory and open `websocket.html` with a web browser.
# Pub/Sub with chunked transfer encoding
# Pub/Sub with chunked transfer encoding
Webdis exposes Redis PUB/SUB channels to HTTP clients, forwarding messages in the channel as they are published by Redis. This is done using chunked transfer encoding.
Webdis exposes Redis PUB/SUB channels to HTTP clients, forwarding messages in the channel as they are published by Redis. This is done using chunked transfer encoding.