Caddy server

目录

  • 1. Caddy server
    • 1.1. what
    • 1.2. `3-LINERS`
    • 1.3. THE CADDYFILE
    • 1.4. CONFIG API

1. Caddy server

1.1. what

Caddy 2 is a powerful, enterprise-ready, open source web server with automatic HTTPS written in Go

  • Fewer moving parts

Caddy simplifies your infrastructure. It takes care of TLS certificate renewals, OCSP stapling, static file serving, reverse proxying, Kubernetes ingress, and more.

Its modular architecture means you can do more with a single, static binary that compiles for any platform.

Caddy runs great in containers because it has no dependencies—not even libc. Run Caddy practically anywhere.

Caddy does the work of your WAF, web server, ingress, reverse proxy, TLS terminator, logging, caching, and TLS certificate management.

  • Best-in-class security

Caddy is the only web server to use HTTPS automatically and by default.

Caddy obtains and renews TLS certificates for your sites automatically. It even staples OCSP responses. Its novel certificate management features are the most mature and reliable in its class.

Written in Go, Caddy offers greater memory safety than servers written in C. A hardened TLS stack powered by the Go standard library serves a significant portion of all Internet traffic.

Caddy is the only server to use HTTPS automatically and by default

  • Backed by Ardan

Ardan Labs is the trusted partner of the Caddy Web Server open source project, providing enterprise-grade support to our clients.

Together, we consult and train, as well as develop, install, and maintain Caddy and its plugins to ensure your infrastructure runs smoothly and efficiently. Contact us to get started!

  • File server and proxy

Caddy is both a flexible, efficient static file server and a powerful, scalable reverse proxy.

Use it to serve your static site with compression, template evaluation, Markdown rendering, and more.

Or use it as a dynamic reverse proxy to any number of backends, complete with active and passive health checks, load balancing, circuit breaking, caching, and more.

1.2. 3-LINERS

These commands are production-ready. When given a domain name, Caddy will use HTTPS by default, which provisions and renews certificates for you.*

Requires domain’s public A/AAAA DNS records pointed at your machine.

  • Quick, local file server: $ caddy file-server
  • Public file server over HTTPS: $ caddy file-server --domain example.com
  • HTTPS reverse proxy: $ caddy reverse-proxy --from example.com --to localhost:9000
  • Run server with Caddyfile in working directory (if present): $ caddy run

1.3. THE CADDYFILE

A config file that’s human-readable and easy to write by hand. Perfect for most common and manual configurations.

  • Local file server with template evaluation
localhost

templates
file_server
  • HTTPS reverse proxy with custom load balancing and active health checks
example.com # Your site's domain name

# Load balance between three backends with custom health checks
reverse_proxy 10.0.0.1:9000 10.0.0.2:9000 10.0.0.3:9000 {
	lb_policy       random_choose 2
	health_path     /ok
	health_interval 10s
}
  • HTTPS site with clean URLs, reverse proxying, compression, and templates
example.com

# Templates give static sites some dynamic features
templates

# Compress responses according to Accept-Encoding headers
encode gzip zstd

# Make HTML file extension optional
try_files {path}.html {path}

# Send API requests to backend
reverse_proxy /api/* localhost:9005

# Serve everything else from the file system
file_server

1.4. CONFIG API

Caddy is dynamically configurable with a RESTful JSON API. Config updates are graceful, even on Windows.

Using JSON gives you absolute control over the edge of your compute platform, and is perfect for dynamic and automated deployments.

  • Set a new configuration
POST /config/

{
  "apps": {
    "http": {
      "servers": {
        "example": {
          "listen": ["127.0.0.1:2080"],
          "routes": [{
            "@id": "demo",
            "handle": [{
              "handler": "file_server",
              "browse": {}
            }]
          }]
        }
      }
    }
  }
}
  • Export current configuration
GET /config/
  • Change only a specific part of the config
PUT /id/demo/handle/0

{"handler": "templates"}

你可能感兴趣的:(golang,caddy,web,server)