Skip to main content
Caddy uses a hierarchical namespace system to organize modules. Understanding this system is essential for creating modules that integrate properly with Caddy’s architecture.

Module ID Structure

A ModuleID is a dot-separated string from modules.go:80:
The structure is:
  • Namespace: All labels except the last (the scope)
  • Name: The last label (the module’s actual name)

Examples

Namespace Methods

From modules.go:103:

Standard Namespaces

Apps (Top-Level)

Namespace: Empty (no dots) Apps are top-level modules that Caddy loads and runs. From modules/standard/imports.go:3:

HTTP Handlers

Namespace: http.handlers Middleware that processes HTTP requests:
From modules/caddyhttp/tracing/module.go:40:

HTTP Matchers

Namespace: http.matchers Request matching logic:

TLS Modules

Namespace: tls.*

Storage Backends

Namespace: caddy.storage Where Caddy stores TLS certificates and other data:

Logging

Namespace: caddy.logging

Events

Namespace: caddy.events Event handling and subscription:

Config Adapters

Namespace: caddy.config_adapters Convert other config formats to Caddy JSON:

Network Proxy

Namespace: caddy.network_proxy Modules must implement ProxyFuncProducer from modules.go:375:

Discovering Modules

Get All Modules in a Namespace

From modules.go:204:
Example usage:
Partial scopes are not matched. "http.handlers" will not match "http.handlers.foo.bar".

Get a Specific Module

From modules.go:164:

List All Registered Modules

From modules.go:244:

Naming Conventions

From the source code and documentation:
1

Use lowercase

Module IDs should be lowercase:
2

Use underscores for spaces

Separate words with underscores, not hyphens or camelCase:
3

Choose appropriate namespace

Place your module in the correct namespace:
4

Make names descriptive

The name should clearly indicate what the module does:

Reserved Module IDs

From modules.go:144:
The module IDs caddy and admin are reserved and will cause a panic if used.

Module Map Configuration

From modules.go:122:
Used in configuration:
The map key is the module name (last part of ID), and the namespace comes from struct tags:

Creating Custom Namespaces

You can create custom namespaces for your organization:
Use a unique prefix (like your company name) to avoid conflicts with other modules.

Best Practices

Follow Standard Namespaces

Use established namespaces when your module fits an existing category

Descriptive Names

Make module names self-documenting and clear

Consistent Naming

Follow the lowercase with underscores convention

Avoid Conflicts

Use unique prefixes for custom namespaces

Next Steps

Module Development

Learn how to create modules

Plugin Tutorial

Build a complete plugin