Embedded Web Server

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
port8080HTTP port
root./htdocsDocument root directory
domainnullDomain for auto-HTTPS
autoHttpsfalseEnable Let's Encrypt SSL
phpEnabledfalseEnable PHP via FastCGI
phpPort9000PHP-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?

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.