Webdis Documentation

repository·master·Indexed 25 days ago

https://github.com/nicolasff/webdis

Webdis is a lightweight web server that provides a RESTful HTTP interface to Redis. It allows users to interact with Redis commands via HTTP GET, POST, and PUT requests, supporting various output formats (JSON, MessagePack, XML, etc.), WebSocket connectivity, and Redis Pub/Sub via chunked transfer encoding. The documentation covers installation from source, Docker deployment, SSL/TLS configuration, ACL management, and the use of the embedded Hiredis C client library.

Tokens
13K
Snippets
40
Records
76
Agent score
81%

What's inside Webdis

  1. Overview of Hiredis

    master

    Hiredis is a minimalistic C client library for the Redis database (version >= 1.2.0). It provides a high-level, printf-like API for sending commands and receiving replies. The library is divided into three main APIs:

    1. Synchronous API: For blocking command execution.
    2. Asynchronous API: For non-blocking operations.
    3. Reply Parsing API: A decoupled stream parser designed for reusability in higher-level language bindings.
  2. Use the HTTP Parser for requests and responses

    master

    The http_parser is a high-performance C parser for HTTP messages (both requests and responses). It is designed for performance-critical applications, performing no syscalls or allocations and requiring only ~40 bytes of data per stream.

    Key features:

    • Handles persistent streams (keep-alive).
    • Decodes chunked encoding transparently.
    • Supports protocol upgrades (e.g., WebSockets).
    • Defends against buffer overflow attacks.
    • Extracts headers, Content-Length, method, status code, version, path, query string, and body.
  3. Understand the multi-architecture Webdis release structure

    master

    Webdis multi-architecture releases use manifest lists for both Docker Hub and AWS Elastic Container Registry (ECR). A single release tag (e.g., 0.1.19) points to a manifest list, which in turn points to individual manifests for specific architectures (like amd64 or arm64).

    To inspect the manifest list for a specific version and see the available architectures and their respective manifest digests, use docker manifest inspect.

    $ docker manifest inspect docker.io/nicolas/webdis:0.1.19
  4. Verify the integrity of a Docker Hub manifest list

    master

    You can verify that a Webdis manifest list on Docker Hub has not been altered by computing its SHA-256 digest and comparing it to the Digest provided by docker trust inspect.

    Important: When computing the digest manually, you must remove the terminating newline that Docker adds to the output. Use perl -pe 'chomp if eof' before hashing.

  5. Verify Webdis Docker images via Docker Content Trust (Deprecated)

    master

    ⚠️ DEPRECATED: As of release 0.1.24, Webdis uses cosign for signing. The following instructions apply only to Webdis releases 0.1.12 through 0.1.23 which use Docker Content Trust (DCT).

    To verify that a Webdis image is legitimate and was built by the official author, you can use docker trust inspect if you are pulling from Docker Hub. If you are pulling from AWS ECR, you must manually compare the image digest with a verified image from Docker Hub.

  6. Verify Webdis Docker image signatures

    master
    Webdis images are signed with cosign. To verify the integrity of an image from Docker Hub or Amazon ECR, use the cosign verify command with the webdis.pub public key found in the repository root.
  7. Verify specific architectures in multi-arch Webdis images

    master
    Webdis uses a multi-architecture OCI index (supporting linux/amd64 and linux/arm64). While verifying the tag (the index) is usually sufficient, you can verify a specific architecture by resolving its digest from the index and passing that digest to cosign verify.
  8. Create a dump.rdb file using Webdis and Docker

    master

    To generate a dump.rdb file from a Webdis container, follow these steps:

    1. Create a local directory for data: mkdir ./redis-data.
    2. Start a Webdis container mounting this directory to /var/lib/redis:
      docker run -d --rm --name webdis-local -v$(pwd)/redis-data:/var/lib/redis -p127.0.0.1:7379:7379 nicolas/webdis:latest
    3. Write keys using the Webdis HTTP API:
      curl -s http://127.0.0.1:7379/SET/hello/world
      curl -s http://127.0.0.1:7379/SET/foo/bar
    4. Force Redis to persist the data to disk using the SAVE command:
      curl -s http://127.0.0.1:7379/SAVE
    5. Stop the container to ensure the file is written and the container is cleaned up:
      docker stop webdis-local

    The dump.rdb file will now be available in your local ./redis-data directory.

    $ mkdir ./redis-data
    
    $ docker run -d --rm --name webdis-local -v$(pwd)/redis-data:/var/lib/redis \
        -p127.0.0.1:7379:7379 nicolas/webdis:latest
    
    $ curl -s http://127.0.0.1:7379/SET/hello/world
    $ curl -s http://127.0.0.1:7379/SET/foo/bar
    $ curl -s http://127.0.0.1:7379/SAVE
    
    $ docker stop webdis-local