Provide Feedback

WasmX

The power of WebAssembly Proxy Extensions on Kong API Gateway

WasmX for Kong API Gateway enables developers to write Wasm packet filters in their preferred language and deploy them to both Kong or Envoy based dataplanes.

Benefits of Wasm Nginx Module

  • Wasm enables powerful and performant extensibility of your datapath.
  • Sharing a common extension ecosystem strengthens community growth.
  • Nginx is the most performant foundation for the world class Kong API Gateway.

What is WebAssembly?

First designed as an enhancement for modern web browsers, WebAssembly (Wasm) joined HTML, CSS, and JavaScript to be announced as the fourth W3C recommended "language for the Web". Wasm enabled Ahead of Time compiled (AOT) binaries to run in the browser unlocking new capabilities in the client rendered internet.

The Wasm System Interface (WASI) project extended Wasm beyond the browser by establishing the needed Application Binary Interface (ABI) standardization effort to formally build ecosystems of server-side Wasm applications.

What is WebAssembly for Proxies?

Wasm extensions depend on a proxy exposing an embedded Wasm runtime. First featured in the Envoy Proxy, Wasm for Proxies defines a standard integration spec to facilitate communication between the proxy host program and data filter extensions over the Wasi ABI.

Supported Runtimes

Get Started:

The following steps will demonstrate a very basic Wasm packet header extension running in the WasmX module on Kong API Gateway with docker.

The plugin will add the following headers to the response packet:

    Cowsay: Hello World
    Powered-By: proxy-wasm

Dependencies:

  1. Make sure you have all dependencies

    Click to expand dependency check command
    bash -c "cat <<EOF | bash -es --
    git --version
    httpie --version
    docker --version
    EOF"
  1. Clone a proxy-wasm filter repo: proxy_wasm_hello_world

    git clone https://github.com/Kong/proxy-wasm-hello-world wasm
  1. Run Kong API Gateway:

    curl -Ls https://get.konghq.com/quickstart | bash -s -- -i incubator -t gateway-wasmer-3.0.0.0 \
    -e "KONG_WASM=on" -e "KONG_WASM_MODULES=/wasm/proxy_wasm_hello_world.wasm" -v $(pwd)/wasm:/wasm
  1. Create a Mockbin.com demo Service:

    http POST :8001/services/ name="mockbin" host="mockbin.com" path="/bin/ccb2968e-08e8-43af-babd-878c9f269486" protocol="http"
  1. Create a Mockbin.com demo Route:
    http POST :8001/services/mockbin/routes name="mockbin" "paths[]=/mockbin"
  1. Configure proxy-wasm filter proxy_wasm_hello_world on the mockbin route:
    http POST :8001/services/mockbin/plugins name="proxy-wasm" "config[filters][0][name]=proxy_wasm_hello_world"
  1. Check for header: Cowsay: Hello World

    http GET :8000/mockbin
    • Result:
    
        HTTP/1.1 200 OK
        Connection: keep-alive
        Content-Length: 15
        Cowsay: Hello World
        Date: Wed, 21 Sep 2022 22:46:01 GMT
        Powered-By: proxy-wasm
        Server: nginx
        Via: kong/3.0.0.0-enterprise-edition
        X-Kong-Proxy-Latency: 340
        X-Kong-Upstream-Latency: 0
    
        Hello, World!
    

Product

Gateway

Stability

Tech Preview