wasm

The wasm directive configures WebAssembly support in NGINX, enabling the use of WebAssembly modules to extend functionality.

Syntaxwasm { module name path.{wasm,wat}; }
Defaultnone
Contextmain
Argumentsnone

Description

The wasm directive is used to enable and configure WebAssembly (Wasm) support in NGINX, allowing users to embed WebAssembly runtimes within the NGINX server. This directive establishes a context for loading and managing Wasm modules that can be executed in response to various HTTP events and phases traversed by a request through the server. By using wasm, developers can define modules that encapsulate custom logic and use proxy-wasm to manipulate requests and responses dynamically, enhancing the capabilities of the web server.

Specifically, users can load Wasm modules into NGINX that implement filters or other processing logic using languages such as Rust or Go. The configuration allows the declaration of multiple Wasm modules by specifying module names and paths to the compiled .wasm files. The corresponding functionality can then be invoked in various NGINX contexts, such as during request processing or access phases, allowing for powerful extensibility through custom WebAssembly logic.

Config Example

wasm {
    module my_filter /path/to/filter.wasm;
    module my_module /path/to/module.wasm;
}

Ensure Wasm module paths are correct and accessible by NGINX.

Modules must be compiled correctly for the intended target and NGINX version.

Debugging Wasm modules may require enabling debug logging in NGINX.

← Back to all directives