Skip to the content.

Configuration

This document describes the configuration structure for the Vetis web server.

Overview

The configuration file defines server listeners and virtual hosts for routing HTTP requests. The server supports multiple interfaces, SSL/TLS, and flexible static file serving.

Configuration Structure

Server Section

Defines the main server settings and listening interfaces.

server:
  listeners:
    - interface: "0.0.0.0"
      port: 8080
      protocol: "Http1"

Listener Configuration

Virtual Hosts Section

Defines virtual host configurations for handling different domains or paths.

virtual_hosts:
  - hostname: "localhost"
    port: 8080
    root_directory: "/home/rogerio/Documentos/Temp/vetis"
    enable_logging: false
    error_pages:
      404: "404.html"
    static_paths:
      - uri: "/"
        directory: "/home/rogerio/Documentos/Temp/vetis/static"
        extensions: "\\.(html)$"
        index_files:
          - "index.html"

Virtual Host Configuration

Error Pages Configuration

Custom error pages for different HTTP status codes:

error_pages:
  404: "404.html"
  500: "500.html"
  403: "forbidden.html"

Static Paths Configuration

Defines URL patterns for serving static files:

static_paths:
  - uri: "/"
    directory: "/home/rogerio/Documentos/Temp/vetis/static"
    extensions: "\\.(html)$"
    index_files:
      - "index.html"

Example Configurations

Basic Development Server

server:
  listeners:
    - interface: "127.0.0.1"
      port: 3000
      protocol: "Http1"

virtual_hosts:
  - hostname: "localhost"
    port: 3000
    root_directory: "./public"
    enable_logging: true
    static_paths:
      - uri: "/"
        directory: "./public"
        extensions: ".*"
        index_files:
          - "index.html"

Production HTTPS Server

server:
  listeners:
    - interface: "0.0.0.0"
      port: 443
      protocol: "Http2"

virtual_hosts:
  - hostname: "example.com"
    port: 443
    root_directory: "/var/www/example.com"
    enable_logging: true
    error_pages:
      404: "errors/404.html"
      500: "errors/500.html"
    static_paths:
      - uri: "/"
        directory: "/var/www/example.com/public"
        extensions: "\\.(html|css|js|png|jpg|gif|svg)$"
        index_files:
          - "index.html"

Security Considerations

  1. Interface Binding: Use "127.0.0.1" for development to prevent external access
  2. SSL Configuration: Always enable SSL in production environments
  3. File Extensions: Restrict file extensions to prevent serving sensitive files
  4. Directory Traversal: Ensure directory paths are properly validated
  5. Logging: Enable logging in production for security monitoring

Performance Tips

  1. Disable Logging: Set enable_logging: false in production for better performance
  2. HTTP/2: Use "Http2" protocol for better multiplexing
  3. Static File Caching: Configure appropriate cache headers for static assets
  4. File Extension Filtering: Limit extensions to reduce unnecessary file system checks

Troubleshooting

Common Issues

Debug Mode

Enable logging to troubleshoot routing and file serving issues:

virtual_hosts:
  - hostname: "localhost"
    port: 8080
    root_directory: "./public"
    enable_logging: true