Embedded Web Server
Base CampHTTP REST API & Automatic HTTPS
YAKMESH includes an optional embedded web server powered by Caddy, enabling true self-hosting with automatic HTTPS.
Quick Start
import { YakmeshWebServer } from 'yakmesh/webserver';
const server = new YakmeshWebServer({
port: 8080,
root: './htdocs'
});
await server.start();
// Web server running at http://localhost:8080
CLI Usage
# Install Caddy (automatic on first start)
npx yakmesh web install
# Start web server
npx yakmesh web start --port 8080 --root ./htdocs
# With automatic HTTPS (requires domain pointed to your server)
npx yakmesh web start --domain mysite.com --https
Configuration Options
| Option | Default | Description |
|---|---|---|
port | 8080 | HTTP port |
root | ./htdocs | Document root directory |
domain | null | Domain for auto-HTTPS |
autoHttps | false | Enable Let's Encrypt SSL |
phpEnabled | false | Enable PHP via FastCGI |
phpPort | 9000 | PHP-FPM/CGI port |
Full Stack Example
Run the mesh network AND web server together:
import { YakmeshNode } from 'yakmesh';
import { YakmeshWebServer } from 'yakmesh/webserver';
// Start mesh node
const mesh = new YakmeshNode({ port: 9001 });
await mesh.start();
// Start web server
const web = new YakmeshWebServer({ port: 8080 });
await web.start();
// Now you have:
// - Mesh network on ws://localhost:9001
// - Website on http://localhost:8080
Why Caddy?
- Automatic HTTPS - Free SSL via Let's Encrypt, zero config
- Single Binary - No dependencies, just drop in and run
- Cross-Platform - Windows, Linux, macOS, ARM
- Open Source - Apache 2.0 license, no royalties
- Modern - HTTP/2, HTTP/3, WebSockets out of the box
PHP Support
To run PHP applications (like phpBB), you need php-cgi running:
# Start PHP FastCGI (in another terminal)
php-cgi -b 127.0.0.1:9000
# Then start YAKMESH with PHP enabled
npx yakmesh web start --php --root ./htdocs
Self-Hosting Philosophy
YAKMESH is built for digital sovereignty. The embedded web server means you don't need to rely on third-party hosting. Your node, your website, your data - all running from a single command.