Traditional Server Deployment

Deploy your Nixi application on traditional servers using reverse proxies. This guide covers Ubuntu/Debian, CentOS, and macOS.

Prerequisites

Installation on Different OS

Ubuntu/Debian

# Update package lists
sudo apt-get update

# Install Lua and dependencies
sudo apt-get install -y lua5.4 liblua5.4-dev luarocks

# Install required Lua packages
sudo luarocks install luasocket
sudo luarocks install luafilesystem

# Verify installation
lua -v

CentOS/RHEL/Fedora

# CentOS/RHEL 8+
sudo dnf install -y lua lua-devel luarocks

# CentOS 7
sudo yum install -y lua lua-devel luarocks

# Install required Lua packages
sudo luarocks install luasocket
sudo luarocks install luafilesystem

# Verify installation
lua -v

macOS

# Using Homebrew (recommended)
brew install lua luarocks

# Install required Lua packages
luarocks install luasocket
luarocks install luafilesystem

# Verify installation
lua -v

Running Your Application

Start your Nixi application:

# Navigate to your project directory
cd /path/to/your-nixi-app

# Run the server
lua server.lua

# Or if using the CLI
nixi dev

The server will start on the port configured in your app (default 3000).

Nginx Reverse Proxy Setup

Configure Nginx as a reverse proxy to forward requests to your Nixi application:

Basic Configuration

# /etc/nginx/sites-available/nixi-app
server {
    listen 80;
    server_name yourdomain.com;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        
        proxy_connect_timeout 60s;
        proxy_send_timeout 60s;
        proxy_read_timeout 60s;
    }
}

SSL/TLS Configuration

# /etc/nginx/sites-available/nixi-app
server {
    listen 80;
    server_name yourdomain.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        
        proxy_buffering off;
        proxy_cache off;
    }

    location /static/ {
        alias /opt/my-nixi-app/public/;
        expires 30d;
        add_header Cache-Control "public, immutable";
    }
}

Enabling Nginx Configuration

# Create symbolic link to enable site
sudo ln -s /etc/nginx/sites-available/nixi-app /etc/nginx/sites-enabled/

# Test configuration
sudo nginx -t

# Reload nginx
sudo nginx -s reload

Firewall Configuration

UFW (Ubuntu/Debian)

# Allow SSH (important before enabling firewall!)
sudo ufw allow 22/tcp

# Allow HTTP and HTTPS
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

# Enable firewall
sudo ufw enable

# Check status
sudo ufw status

firewalld (CentOS/RHEL)

# Allow HTTP and HTTPS
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https

# Reload firewall
sudo firewall-cmd --reload

# Check status
sudo firewall-cmd --list-all

Static Site Deployment

Deploy your Nixi app as a static site to Vercel, Cloudflare Pages, Netlify, GitHub Pages, or any static hosting.

Build the Static Site

# Build to ./build/ directory
nixi build

# Or build to a custom directory
nixi build dist/

Configuration

Create nixi.config.json for dynamic routes:

{
  "build": {
    "output": "build",
    "dynamicValues": {
      "/users/:id": [
        { "id": "1" },
        { "id": "2" }
      ]
    },
    "skipRoutes": ["/api/*"]
  }
}

Vercel

# vercel.json
{
  "buildCommand": "nixi build",
  "outputDirectory": "build",
  "rewrites": [
    { "source": "/(.*)", "destination": "/index.html" }
  ]
}

Cloudflare Pages

Set build command: nixi build

Build output directory: build

Netlify

# netlify.toml
[build]
  command = "nixi build"
  publish = "build"

[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200

Output Structure

build/
├── index.html           # Homepage
├── about/
│   └── index.html     # /about page
├── css/
│   └── style.css     # Compiled CSS
├── 404.html           # Error page
└── public/            # Static assets

Production Checklist

Item Description
Port Binding Bind to 127.0.0.1 behind proxy
Logging Configure log rotation
SSL Certificate Use valid HTTPS certificate
Health Check Set up monitoring endpoint
Backups Configure automated backups