All Projects → api7 → wasm-nginx-module

api7 / wasm-nginx-module

Licence: Apache-2.0 License
Run Wasm in OpenResty/Nginx

Programming Languages

c
50402 projects - #5 most used programming language
perl
6916 projects
lua
6591 projects
python
139335 projects - #7 most used programming language
Raku
181 projects
shell
77523 projects
Makefile
30231 projects

Projects that are alternatives of or similar to wasm-nginx-module

redstone-smartcontracts
An implementation of the Arweave SmartWeave smart contracts protocol.
Stars: ✭ 42 (-23.64%)
Mutual labels:  wasm
lua-resty-tarpit
OpenResty response time inflation
Stars: ✭ 25 (-54.55%)
Mutual labels:  openresty
wrangler2
🤠 wrangle your Cloudflare Workers
Stars: ✭ 349 (+534.55%)
Mutual labels:  wasm
image-hub
Image Hub is a sample application for exploring WebAssembly modules used as Envoy filters.
Stars: ✭ 56 (+1.82%)
Mutual labels:  wasm
cabasa
Haxe Framework for WebAssembly
Stars: ✭ 30 (-45.45%)
Mutual labels:  wasm
wasm-extension-template
An easy-to-use template for Rust web extensions. The Rust code is compiled to WASM and ran as a content script.
Stars: ✭ 78 (+41.82%)
Mutual labels:  wasm
as-sha256
AssemblyScript implementation of SHA256
Stars: ✭ 15 (-72.73%)
Mutual labels:  wasm
lua-resty-jump-consistent-hash
consistent hash for openresty
Stars: ✭ 24 (-56.36%)
Mutual labels:  openresty
wasi-worker
WASM / WASI interface for browser service workers
Stars: ✭ 31 (-43.64%)
Mutual labels:  wasm
block-aligner
SIMD-accelerated library for computing global and X-drop affine gap penalty sequence-to-sequence or sequence-to-profile alignments using an adaptive block-based algorithm.
Stars: ✭ 58 (+5.45%)
Mutual labels:  wasm
ybc
A Yew component library based on the Bulma CSS framework.
Stars: ✭ 131 (+138.18%)
Mutual labels:  wasm
lua-resty-aries
openresty and lua multi-function template
Stars: ✭ 47 (-14.55%)
Mutual labels:  openresty
tarmac
Framework for building distributed services with Web Assembly
Stars: ✭ 55 (+0%)
Mutual labels:  wasm
cdn-up-and-running
CDN Up and Running - an introduction about how modern CDNs works
Stars: ✭ 131 (+138.18%)
Mutual labels:  openresty
lua-resty-danmaku
Live danmaku server in OpenResty (WIP)
Stars: ✭ 12 (-78.18%)
Mutual labels:  openresty
rust-wasm-on-lambda-edge
Rust/WASM on AWS Lambda@Edge (CloudFront)
Stars: ✭ 12 (-78.18%)
Mutual labels:  wasm
lua-resty-acme
Automatic Let's Encrypt certificate serving and Lua implementation of ACMEv2 procotol
Stars: ✭ 95 (+72.73%)
Mutual labels:  openresty
blazor-ui
A collection of examples related to Telerik UI for Blazor Components: https://www.telerik.com/blazor-ui
Stars: ✭ 182 (+230.91%)
Mutual labels:  wasm
rustwasmc
Tool for building Rust functions for Node.js. Combine the performance of Rust, safety and portability of WebAssembly, and ease of use of JavaScript.
Stars: ✭ 97 (+76.36%)
Mutual labels:  wasm
Warp
Warp is a blazingly-fast modern Rust based GPU-accelerated terminal built to make you and your team more productive.
Stars: ✭ 1,319 (+2298.18%)
Mutual labels:  wasm

Status

This library is under construction. See #25 to know the progress.

Description

A Nginx module which tries to implement proxy wasm ABI in Nginx. The Wasm integration of Apache APISIX is powered by this module.

Install dependencies

  • Download the wasmtime C API package and rename it to wasmtime-c-api/, with the ./install-wasmtime.sh. Remember to add the wasmtime-c-api/lib to the library search path when you build Nginx, for instance,
export wasmtime_prefix=/path/to/wasm-nginx-module/wasmtime-c-api
./configure ... \
    --with-ld-opt="-Wl,-rpath,${wasmtime_prefix}/lib" \

Directives

wasm_vm

syntax: wasm_vm wasmtime

default: -

context: http

Select the Wasm VM. Currently, only wasmtime is supported. If the directive is not set, the Wasm VM won't be enabled.

Methods

Remember to set the wasm_vm directive!

load

syntax: plugin, err = proxy_wasm.load(name, path)

Load a .wasm file from the filesystem and return a Wasm plugin.

local plugin, err = proxy_wasm.load("plugin","t/testdata/plugin_lifecycle/main.go.wasm")

on_configure

syntax: plugin_ctx, err = proxy_wasm.on_configure(plugin, conf)

Create a plugin ctx with the given plugin and conf.

local plugin, err = proxy_wasm.load("plugin","t/testdata/plugin_lifecycle/main.go.wasm")
if not plugin then
    ngx.log(ngx.ERR, "failed to load wasm ", err)
    return
end
local ctx, err = wasm.on_configure(plugin, '{"body":512}')
if not ctx then
    ngx.log(ngx.ERR, "failed to create plugin ctx ", err)
    return
end

on_http_request_headers

syntax: ok, err = proxy_wasm.on_http_request_headers(plugin_ctx)

Run the HTTP request headers filter in the plugin of the given plugin ctx.

local plugin, err = proxy_wasm.load("plugin","t/testdata/plugin_lifecycle/main.go.wasm")
if not plugin then
    ngx.log(ngx.ERR, "failed to load wasm ", err)
    return
end
local ctx, err = wasm.on_configure(plugin, '{"body":512}')
if not ctx then
    ngx.log(ngx.ERR, "failed to create plugin ctx ", err)
    return
end
assert(wasm.on_http_request_headers(ctx))

on_http_request_body

syntax: ok, err = proxy_wasm.on_http_request_body(plugin_ctx, body, end_of_body)

Run the HTTP request body filter in the plugin of the given plugin ctx.

local plugin, err = proxy_wasm.load("plugin","t/testdata/plugin_lifecycle/main.go.wasm")
if not plugin then
    ngx.log(ngx.ERR, "failed to load wasm ", err)
    return
end
local ctx, err = wasm.on_configure(plugin, '{"body":512}')
if not ctx then
    ngx.log(ngx.ERR, "failed to create plugin ctx ", err)
    return
end
-- get_body is a utility method to get the whole request body
local body = request.get_body()
-- if the body is not the whole request body, for example, it comes from
-- lua-resty-upload, remember to set end_of_body to false
assert(wasm.on_http_request_body(ctx, body, true))

on_http_response_headers

syntax: ok, err = proxy_wasm.on_http_response_headers(plugin_ctx)

Run the HTTP response headers filter in the plugin of the given plugin ctx.

local plugin, err = proxy_wasm.load("plugin","t/testdata/http_lifecycle/main.go.wasm")
if not plugin then
    ngx.log(ngx.ERR, "failed to load wasm ", err)
    return
end
local ctx, err = wasm.on_configure(plugin, '{"body":512}')
if not ctx then
    ngx.log(ngx.ERR, "failed to create plugin ctx ", err)
    return
end
assert(wasm.on_http_response_headers(ctx))

on_http_response_body

syntax: ok, err = proxy_wasm.on_http_response_body(plugin_ctx)

Run the HTTP response body filter in the plugin of the given plugin ctx. This method need to be called in body_filter_by_lua phase and may be run multiple times.

local plugin, err = proxy_wasm.load("plugin","t/testdata/http_lifecycle/main.go.wasm")
if not plugin then
    ngx.log(ngx.ERR, "failed to load wasm ", err)
    return
end
local ctx, err = wasm.on_configure(plugin, '{"body":512}')
if not ctx then
    ngx.log(ngx.ERR, "failed to create plugin ctx ", err)
    return
end
assert(wasm.on_http_response_body(ctx))

proxy-wasm ABI

Implemented proxy-wasm ABI can be found in proxy_wasm_abi.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].