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,296
Resource Number 49629 Last Updated 2025-02-21
¥ 0HKD 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/caddy-is-a-scalable-server-platform-that-uses-tls-by-default/

Qizhuwang Source Code Trading Platform

Q&A
  • 1. Automatic: After making an online payment, click the (Download) link to download the source code; 2. Manual: Contact the seller or the official to check if the template is consistent. Then, place an order and make payment online. The seller ships the goods, and both parties inspect and confirm that there are no issues. ICTcoder will then settle the payment for the seller. Note: Please ensure to place your order and make payment through ICTcoder. If you do not place your order and make payment through ICTcoder, and the seller sends fake source code or encounters any issues, ICTcoder will not assist in resolving them, nor can we guarantee your funds!
View details
  • 1. Default transaction cycle for source code: The seller manually ships the goods within 1-3 days. The amount paid by the user will be held in escrow by ICTcoder until 7 days after the transaction is completed and both parties confirm that there are no issues. ICTcoder will then settle with the seller. In case of any disputes, ICTcoder will have staff to assist in handling until the dispute is resolved or a refund is made! If the buyer places an order and makes payment not through ICTcoder, any issues and disputes have nothing to do with ICTcoder, and ICTcoder will not be responsible for any liabilities!
View details
  • 1. ICTcoder will permanently archive the transaction process between both parties and snapshots of the traded goods to ensure the authenticity, validity, and security of the transaction! 2. ICTcoder cannot guarantee services such as "permanent package updates" and "permanent technical support" after the merchant's commitment. Buyers are advised to identify these services on their own. If necessary, they can contact ICTcoder for assistance; 3. When both website demonstration and image demonstration exist in the source code, and the text descriptions of the website and images are inconsistent, the text description of the image shall prevail as the basis for dispute resolution (excluding special statements or agreements); 4. If there is no statement such as "no legal basis for refund" or similar content, any indication on the product that "once sold, no refunds will be supported" or other similar declarations shall be deemed invalid; 5. Before the buyer places an order and makes payment, the transaction details agreed upon by both parties via WhatsApp or email can also serve as the basis for dispute resolution (in case of any inconsistency between the agreement and the description of the conflict, the agreement shall prevail); 6. Since chat records and email records can serve as the basis for dispute resolution, both parties should only communicate with each other through the contact information left on the system when contacting each other, in order to prevent the other party from denying their own commitments. 7. Although the probability of disputes is low, it is essential to retain important information such as chat records, text messages, and email records, in case a dispute arises, so that ICTcoder can intervene quickly.
View details
  • 1. As a third-party intermediary platform, ICTcoder solely protects transaction security and the rights and interests of both buyers and sellers based on the transaction contract (product description, agreed content before the transaction); 2. For online trading projects not on the ICTcoder platform, any consequences are unrelated to this platform; regardless of the reason why the seller requests an offline transaction, please contact the administrator to report.
View details

Related Source code

ICTcoder Customer Service

24-hour online professional services