No As A Service
  • Rust 93.5%
  • Dockerfile 6.5%
Find a file
Ole-Morten Duesund 858e14a520 Initial commit: Add NaaS (No as a Service) implementation
Add complete NaaS HTTP service implementation with:
- Pure Rust implementation using only standard library
- Multiple response formats (text, JSON, XML, YAML, boolean)
- Embedded web frontend with mobile-responsive design
- Container support with Podman/Docker
- Systemd service configuration
- Health check endpoint
- CORS support

The service always responds with "no" in various formats,
optimized for minimal binary size (~1MB) and fast response times.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-27 16:42:47 +02:00
src Initial commit: Add NaaS (No as a Service) implementation 2025-09-27 16:42:47 +02:00
Cargo.lock Initial commit: Add NaaS (No as a Service) implementation 2025-09-27 16:42:47 +02:00
Cargo.toml Initial commit: Add NaaS (No as a Service) implementation 2025-09-27 16:42:47 +02:00
CLAUDE.md Add CLAUDE.md for Claude Code guidance 2025-09-27 16:35:55 +02:00
Containerfile Initial commit: Add NaaS (No as a Service) implementation 2025-09-27 16:42:47 +02:00
naas.service Initial commit: Add NaaS (No as a Service) implementation 2025-09-27 16:42:47 +02:00
README.md Update README to use Caddy instead of nginx 2025-09-27 16:36:44 +02:00

No as a Service (NaaS)

A lightweight, production-ready HTTP service that always says "no" in various formats.

Features

  • Minimal dependencies (pure Rust, standard library only)
  • Multiple response formats (text, JSON, XML, YAML, boolean)
  • Mobile-responsive web frontend
  • CORS support
  • Health check endpoint
  • Optimized for small binary size (~1MB)
  • Container-ready with health checks

API Endpoints

  • GET / - Web frontend
  • GET /api/no - Returns plain text "no"
  • GET /api/no?format=json - Returns {"answer": "no"}
  • GET /api/no?format=bool - Returns false
  • GET /api/no?format=xml - Returns XML response
  • GET /api/no?format=yaml - Returns YAML response
  • GET /health - Health check endpoint

Quick Start

Local Development

# Build and run locally
cd naas
cargo build --release
PORT=8080 ./target/release/naas

Visit http://localhost:8080

Container Deployment with Podman

# Build container
cd naas
BUILDAH_FORMAT=docker podman build -t naas:latest -f Containerfile .

# Run container
podman run -d \
  --name naas \
  -p 8080:8080 \
  --restart=always \
  naas:latest

# Check health
curl http://localhost:8080/health

Systemd Service Deployment

  1. Setup user and directory:
# Create service user
sudo useradd -r -s /bin/false naas

# Copy application files
sudo mkdir -p /opt/naas
sudo cp -r naas/* /opt/naas/
sudo chown -R naas:naas /opt/naas
  1. Install systemd service:
# Copy service file
sudo cp naas/naas.service /etc/systemd/system/

# Reload systemd and start service
sudo systemctl daemon-reload
sudo systemctl enable naas
sudo systemctl start naas

# Check status
sudo systemctl status naas
  1. View logs:
sudo journalctl -u naas -f

Production Deployment to no.donothireus.com

Caddy Reverse Proxy Configuration

no.donothireus.com {
    reverse_proxy localhost:8080 {
        header_up Host {host}
        header_up X-Real-IP {remote_host}
        header_up X-Forwarded-For {remote_host}
        header_up X-Forwarded-Proto {scheme}
    }
}

Full Production Setup

  1. Deploy application using systemd service (see above)

  2. Configure Caddy with the above Caddyfile configuration (SSL certificates are automatic with Caddy)

  3. Restart services:

sudo systemctl restart caddy
sudo systemctl restart naas

Performance

  • Binary size: ~1MB (release build with optimizations)
  • Memory usage: <10MB
  • Startup time: <100ms
  • Request latency: <1ms

Development

Building from Source

# Debug build
cargo build

# Release build with optimizations
cargo build --release

# Run tests
cargo test

Container Build Options

# Multi-platform build (if needed)
podman build --platform linux/amd64,linux/arm64 -t naas:latest .

# Build with specific Rust version
podman build --build-arg RUST_VERSION=1.75 -t naas:latest .

Security

  • Runs as non-root user (UID 1000)
  • Read-only container filesystem
  • No new privileges
  • All capabilities dropped except NET_BIND_SERVICE
  • Memory and CPU limits enforced
  • CORS headers properly configured

License

MIT