Skip to main content
The Static service provides a streamlined way to serve static content on Zerops. Built on Nginx but with a simplified configuration interface, it abstracts away complexity while maintaining the flexibility needed for modern web applications.

Key Features

Simplified Configuration

Instead of writing Nginx configuration directly, use YAML-based routing rules that are automatically translated into optimized Nginx configs. Focus on what your app needs, not how to configure a web server.

Smart Default Routing

Out of the box, the Static service handles common patterns for modern web applications:
  1. Try exact path (/about/about)
  2. Try with HTML extension (/about/about.html)
  3. Try directory index (/docs/docs/index.html)
  4. Fall back to SPA routing (/app/route/index.html)
  5. Return 404 if nothing matches
Single Page Applications work without any configuration. The automatic fallback to /index.html ensures client-side routing works correctly.

Advanced Routing Features

  • Masked redirects: Show content from another URL while keeping the original URL
  • Wildcard patterns: Handle multiple routes with a single rule
  • Domain management: Redirect between multiple domains
  • Path preservation: Keep paths when redirecting
  • Query preservation: Maintain query parameters across redirects

Built-in CORS Support

Enable CORS with a single configuration line. No need to understand Nginx’s add_header directives.

Custom Headers

Add security headers, cache control, or any custom headers with simple YAML configuration.

SEO Optimization

Integrated Prerender.io support ensures search engines, social media crawlers, and AI tools can properly index your content.

When to Use Static Service

Perfect For:

  • Single Page Applications (React, Vue, Angular, Svelte)
  • Static site generators (Gatsby, Next.js static export, Nuxt static)
  • Documentation sites (Docusaurus, VitePress, MkDocs)
  • Landing pages and marketing sites
  • Simple static websites

Consider Full Nginx If:

  • You need complete control over Nginx configuration
  • You have complex server-side logic requirements
  • You need custom Nginx modules
  • You want to use advanced Nginx features not exposed by the Static service
You can always switch from Static to full Nginx later. Zerops provides a migration tool that converts your Static configuration to a full Nginx config you can use as a starting point.

Basic Configuration

Minimal zerops.yaml for a static service:
zerops:
  - setup: app
    run:
      base: static
This simple configuration gives you:
  • Optimized Nginx server
  • SPA-friendly routing
  • Alpine Linux base
  • Automatic scaling

Routing Configuration

Simple Redirects

zerops:
  - setup: app
    run:
      base: static
      routing:
        redirects:
          # Permanent redirect
          - from: /old-page
            to: /new-page
            status: 301
          
          # Masked redirect (shows /about content but keeps URL)
          - from: /about
            to: /about-us

Domain Management

zerops:
  - setup: app
    run:
      base: static
      routing:
        redirects:
          # Redirect entire domain
          - from: https://old-domain.com/*
            to: https://new-domain.com
            status: 301
            preserveQuery: true
          
          # Campaign-specific domain
          - from: https://promo.example.com/*
            to: https://example.com/campaign
            status: 302

CORS Configuration

zerops:
  - setup: app
    run:
      base: static
      routing:
        # Simple CORS (allows all origins)
        cors: "*"
        
        # Or with Nginx syntax
        cors: "'*' always"

Custom Headers

zerops:
  - setup: app
    run:
      base: static
      routing:
        headers:
          - for: "/"
            values:
              X-Frame-Options: "'DENY'"
              X-Content-Type-Options: "'nosniff' always"
              Content-Security-Policy: '"default-src ''self''" always'
Header values are inserted directly into Nginx configuration. Always include proper quotes:
  • Simple values: "'DENY'"
  • Values with internal quotes: '"default-src ''self''"
  • With ‘always’ directive: "'value' always"

Framework Integration

The Static service works with any framework that generates static files:
zerops:
  - setup: app
    build:
      base: nodejs@20
      buildCommands:
        - npm install
        - npm run build
      deployFiles:
        - dist/~  # Your framework's output directory
    run:
      base: static
Popular frameworks:
  • React: Deploy build/ or dist/
  • Vue: Deploy dist/
  • Angular: Deploy dist/<project-name>/
  • Svelte: Deploy build/ or dist/
  • Next.js: Deploy .next/ (static export)
  • Nuxt: Deploy .output/public/
  • Gatsby: Deploy public/

SEO with Prerender

Enable Prerender.io to make your SPA SEO-friendly:
  1. Set the PRERENDER_TOKEN secret variable in Zerops GUI
  2. Optionally configure custom host:
zerops:
  - setup: app
    run:
      base: static
      envVariables:
        PRERENDER_HOST: your.prerender.host
Prerender automatically detects crawlers (including AI tools like ChatGPT, Perplexity, and Claude) and serves them pre-rendered HTML while users get the full interactive experience.

Migration to Full Nginx

If you need more control, you can migrate to a full Nginx service:
  1. Go to your Static service in Zerops GUI
  2. Click the three dots (⋮) in the left panel
  3. Select Need to switch to full Nginx service?
  4. Copy the generated Nginx configuration
  5. Use it as a starting point for a full Nginx service
This preserves your routing logic and gives you complete control over Nginx configuration.

Comparison: Static vs Nginx

FeatureStatic ServiceFull Nginx
ConfigurationYAML-based, simplifiedFull Nginx config files
SPA SupportBuilt-in, no config neededManual configuration required
RedirectsSimple YAML rulesNginx rewrite directives
CORSOne-line configurationManual header configuration
Custom HeadersYAML configurationNginx add_header directives
Prerender.ioBuilt-in supportManual configuration
FlexibilityLimited to exposed featuresComplete control
Learning CurveLowRequires Nginx knowledge

Next Steps

Quickstart

Deploy your first static site

Routing Guide

Learn advanced routing patterns

SEO Optimization

Set up Prerender.io

Framework Examples

See framework-specific examples

Build docs developers (and LLMs) love