VMware Labs has unveiled an extension module for Apache's popular web server that runs WebAssembly binaries, opening new possibilities for languages and projects to run securely in Apache.
The mod_wasm extension module allows the Apache HTTP Server to reply to HTTP requests with applications compiled to WebAssembly. Internally, mod_wasm uses the Wasmtime secure runtime to configure and run Wasm modules.
When an Apache HTTP Server is run with mod_wasm enabled, the Wasm module is preloaded into memory as part of a process to speed up request handling by not loading the Wasm module from scratch every time a request is received.
Unveiled on GitHub earlier this month, mod-wasm is composed of two libraries:
- mod_wasm.so, which provides an interface between the Apache C API and Rust library to manage the Wasm runtime. This library is responsible for Apache configuration options and the bindings to connect the Rust library with Apache.
- libwasm._runtime.so, which receives HTTP requests from Apache, configuring and running the Wasm module. It also parses the response and returns control to mod_wasm.so.
WebAssembly, or Wasm, is a binary instruction format and stack-based virtual machine that provides high performance for web applications. It was designed as a portable compilation target for programming languages including C, C++, and Rust.