Caddy is a scalable server platform that uses TLS by default

Caddy is a scalable server platform that uses TLS by default

2022-12-12 0 1,025
Resource Number 49629 Last Updated 2025-02-21
¥ 0USD Upgrade VIP
Download Now Matters needing attention
Can't download? Please contact customer service to submit a link error!
Value-added Service: Installation Guide Environment Configuration Secondary Development Template Modification Source Code Installation

Caddy, recommended in this issue, is a scalable server platform that uses TLS by default.

Caddy is a scalable server platform that uses TLS by default插图

Caddy is a powerful, scalable platform to serve your sites, services, and applications, written in Go. The API configuration using Caddy is dynamic and exportable. Although configuration files are not required, you can still use them; Most people’s favorite way to configure Caddy is to use Caddyfile. Configuration documents come in a variety of formats, with configuration adapters, but Caddy’s native configuration language is JSON.

Characteristic Caddy

  • Easy configuration with Caddyfile
  • Powerful configuration and its native JSON configuration
  • Dynamic configuration using the JSON API
  • If you don’t like JSON, configure the adapter
  • Default automatic HTTPS
  • Stay up and running when other servers are down due to TLS/OCSP/ certificate-related issues
  • After processing trillions of requests and managing millions of TLS certificates, it can be put into production
  • Expands to tens of thousands of sites…… And probably more.
  • HTTP/1.1, HTTP/2, and experimental HTTP/3 support
  • The highly scalable modular architecture allows Caddy to do everything without bloating
  • Run anywhere with no external dependencies (not even libc)
  • Written in Go, a language with higher memory security guarantees than other servers

Caddy installation

Debian、Ubuntu、Raspbian

Installing this package automatically starts and runs caddy as a systemd service named, and if you need it, caddy also comes with a service that is not enabled by default by Caddy-API.

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

Test releases (including beta and release candidates) :

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/testing/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-testing-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/testing/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-testing.list
sudo apt update
sudo apt install caddy

Fedora, Red Hat, CentOS

This package comes with Caddy’s two systemd service unit files, but they are not enabled by default.

Fedora or RHEL/CentOS 8:

dnf install 'dnf-command(copr)'
dnf copr enable @caddy/caddy
dnf install caddy

RHEL/CentOS 7:

yum install yum-plugin-copr
yum copr enable @caddy/caddy
yum install caddy

Webi

Linux  and macOS:

curl -sS https://webinstall.dev/caddy | bash

windows:

curl.exe -A MS https://webinstall.dev/caddy | powershell

You may need to adjust Windows Firewall rules to allow incoming connections from non-local hosts.

Quick start

Start Caddy first:

caddy start

Caddy is currently idle (configured as blank). Give it a simple configuration curl:

curl localhost:2019/load \
    -H "Content-Type: application/json" \
    -d @- << EOF
    {
        "apps": {
            "http": {
                "servers": {
                    "hello": {
                        "listen": [":2015"],
                        "routes": [
                            {
                                "handle": [{
                                    "handler": "static_response",
                                    "body": "Hello, world!"
                                }]
                            }
                        ]
                    }
                }
            }
        }
    }

Using Heredoc to provide POST body can be tedious, so if you prefer to use files, save JSON to a file called caddy.json and then use the following command instead:

curl localhost:2019/load \
  -H "Content-Type: application/json" \
  -d @caddy.json

Now load localhost:2015curl in your browser or use:

curl localhost:2015
Hello, world!

We can also use this JSON to define multiple sites on different interfaces:

{
	"apps": {
		"http": {
			"servers": {
				"hello": {
					"listen": [":2015"],
					"routes": [
						{
							"handle": [{
								"handler": "static_response",
								"body": "Hello, world!"
							}]
						}
					]
				},
				"bye": {
					"listen": [":2016"],
					"routes": [
						{
							"handle": [{
								"handler": "static_response",
								"body": "Goodbye, world!"
							}]
						}
					]
				}
			}
		}
	}
}

Update your JSON and then execute the API request again.

Try the new “goodbye” endpoint in your browser, or use curl to make sure it works:

curl localhost:2016
Goodbye, world!

When Caddy is finished, be sure to stop it:

caddy stop

Reverse proxy Quickstart

Prerequisites:

  • Basic terminal/command line skills
  • caddy is in your path
  • Running back-end processes to proxy to

In your terminal, run the following command:

caddy reverse-proxy --to 127.0.0.1:9000

If you do not have the right to bind to a low-end port, you can proxy from a higher port:

caddy reverse-proxy --from :2016 --to 127.0.0.1:9000

Then make a request to localhost (or whatever address –from you specify in) to see if it works!

In the current working directory, create a file named Caddyfile with the following contents:

localhost

reverse_proxy 127.0.0.1:9000

Then, run from the same directory:

caddy run

You can then make a request to https://localhost to see if it works!

HTTPS and ports

Caddy’s default port is no longer :2015. Caddy 2’s default port is :443, or, if you don’t know the host name /IP, port :80. You can always customize the port in the configuration.

If the host name or IP is known, the default protocol for Caddy 2 is always HTTPS. This is different from Caddy 1, where only public domain names use HTTPS by default. Now, every site uses HTTPS (unless you do this by explicitly specifying the port :80 or disabling it http://).

The IP address and localhost domain will issue the certificate from the local trusted embedded CA. All other fields will use ZeroSSL or Let’s Encrypt. (This is all configurable.)

The storage structure of certificates and ACME resources has changed. Caddy 2 May obtain a new certificate for your site; But if you have a lot of certificates, you can migrate them manually if it doesn’t suit you.

—END—

Open source license: Apache-2.0 license

资源下载此资源为免费资源立即下载
Telegram:@John_Software

Disclaimer: This article is published by a third party and represents the views of the author only and has nothing to do with this website. This site does not make any guarantee or commitment to the authenticity, completeness and timeliness of this article and all or part of its content, please readers for reference only, and please verify the relevant content. The publication or republication of articles by this website for the purpose of conveying more information does not mean that it endorses its views or confirms its description, nor does it mean that this website is responsible for its authenticity.

Ictcoder Free source code Caddy is a scalable server platform that uses TLS by default https://ictcoder.com/kyym/caddy-is-a-scalable-server-platform-that-uses-tls-by-default.html

Qizhuwang Source Code Trading Platform

Q&A
  • 1, automatic: after taking the photo, click the (download) link to download; 2. Manual: After taking the photo, contact the seller to issue it or contact the official to find the developer to ship.
View details
  • 1, the default transaction cycle of the source code: manual delivery of goods for 1-3 days, and the user payment amount will enter the platform guarantee until the completion of the transaction or 3-7 days can be issued, in case of disputes indefinitely extend the collection amount until the dispute is resolved or refunded!
View details
  • 1. Heptalon will permanently archive the process of trading between the two parties and the snapshots of the traded goods to ensure that the transaction is true, effective and safe! 2, Seven PAWS can not guarantee such as "permanent package update", "permanent technical support" and other similar transactions after the merchant commitment, please identify the buyer; 3, in the source code at the same time there is a website demonstration and picture demonstration, and the site is inconsistent with the diagram, the default according to the diagram as the dispute evaluation basis (except for special statements or agreement); 4, in the absence of "no legitimate basis for refund", the commodity written "once sold, no support for refund" and other similar statements, shall be deemed invalid; 5, before the shooting, the transaction content agreed by the two parties on QQ can also be the basis for dispute judgment (agreement and description of the conflict, the agreement shall prevail); 6, because the chat record can be used as the basis for dispute judgment, so when the two sides contact, only communicate with the other party on the QQ and mobile phone number left on the systemhere, in case the other party does not recognize self-commitment. 7, although the probability of disputes is very small, but be sure to retain such important information as chat records, mobile phone messages, etc., in case of disputes, it is convenient for seven PAWS to intervene in rapid processing.
View details
  • 1. As a third-party intermediary platform, Qichou protects the security of the transaction and the rights and interests of both buyers and sellers according to the transaction contract (commodity description, content agreed before the transaction); 2, non-platform online trading projects, any consequences have nothing to do with mutual site; No matter the seller for any reason to require offline transactions, please contact the management report.
View details

Related Article

make a comment
No comments available at the moment
Official customer service team

To solve your worries - 24 hours online professional service