caddy

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package caddy is the web server and reverse proxy configuration tool

Index

Constants

View Source
const GlobalOptionsMarker = "client_ip_headers CF-Connecting-IP"

GlobalOptionsMarker identifies a main Caddyfile whose global block already carries the real-client-IP settings.

Variables

View Source
var CloudflareProxyRanges = []string{
	"173.245.48.0/20", "103.21.244.0/22", "103.22.200.0/22", "103.31.4.0/22",
	"141.101.64.0/18", "108.162.192.0/18", "190.93.240.0/20", "188.114.96.0/20",
	"197.234.240.0/22", "198.41.128.0/17", "162.158.0.0/15", "104.16.0.0/13",
	"104.24.0.0/14", "172.64.0.0/13", "131.0.72.0/22",
	"2400:cb00::/32", "2606:4700::/32", "2803:f800::/32", "2405:b500::/32",
	"2405:8100::/32", "2a06:98c0::/29", "2c0f:f248::/32",
}

CloudflareProxyRanges are Cloudflare's published edge ranges (https://www.cloudflare.com/ips/). They change rarely; when they do, update this list and re-ship — EnsureMainCaddyfile rewrites the global block.

Functions

func GenerateCaddyfile

func GenerateCaddyfile(appName, domain, outputMode string, port int, appDir string, features *nextcore.DetectedFeatures, distDir, exportDir string, sidecarPorts ...int) string

func GlobalOptions added in v1.3.0

func GlobalOptions() string

GlobalOptions is the canonical global options block for /etc/caddy/Caddyfile.

trusted_proxies + client_ip_headers make Caddy resolve the REAL visitor IP when a domain is proxied through Cloudflare (orange cloud). Without them client_ip is a Cloudflare edge address: country stats are wrong and the fail2ban jail bans Cloudflare itself, locking out real users. Only requests that actually arrive from a Cloudflare range may set the header, so a direct-to-origin client cannot spoof its IP.

func UpgradeGlobalOptions added in v1.3.0

func UpgradeGlobalOptions(content string) (string, bool)

UpgradeGlobalOptions rewrites the legacy NextDeploy global block ("{\n\torder coraza_waf first\n}") to GlobalOptions(). Content that already has the marker, or a hand-edited global block it doesn't recognise, is returned unchanged with ok=false so an operator's customisation is never clobbered.

Types

type CaddyManager

type CaddyManager struct {
	// contains filtered or unexported fields
}

func New

func New(adminAPI string) *CaddyManager

func (*CaddyManager) ApplyConfig

func (cm *CaddyManager) ApplyConfig(ctx context.Context, config *Config) error

func (*CaddyManager) GetConfig

func (cm *CaddyManager) GetConfig(ctx context.Context) (*Config, error)

func (*CaddyManager) LoadConfig

func (cm *CaddyManager) LoadConfig(filePath string) (*Config, error)

func (*CaddyManager) PatchConfig

func (cm *CaddyManager) PatchConfig(ctx context.Context, path string, config any) error

func (*CaddyManager) SaveConfig

func (cm *CaddyManager) SaveConfig(config *Config, filePath string) error

func (*CaddyManager) ValidateConfig

func (cm *CaddyManager) ValidateConfig(ctx context.Context, config *Config) error

type Config

type Config struct {
	Content string
	Format  string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL