Skip to content

Commit d47c2f7

Browse files
authored
docs: Various clarifications
* docs: Getting Started -> Intro, new Getting Started Several other smaller improvements and clarifications. * Replace original Getting Started for now * Fix title Started in #263 - will handle new Introduction article another time
1 parent c429966 commit d47c2f7

File tree

5 files changed

+63
-49
lines changed

5 files changed

+63
-49
lines changed

src/docs/markdown/automatic-https.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ In addition, hostnames qualify for publicly-trusted certificates if they:
122122

123123
## Local HTTPS
124124

125+
Caddy uses HTTPS automatically for all sites with a host (domain, IP, or hostname) specified, including internal and local hosts. Some hosts are either not public (e.g. `127.0.0.1`, `localhost`) or do not generally qualify for publicly-trusted certificates (e.g. IP addresses -- you can get certificates for them, but only from some CAs). These are still served over HTTPS unless disabled.
126+
125127
To serve non-public sites over HTTPS, Caddy generates its own certificate authority (CA) and uses it to sign certificates. The trust chain consists of a root and intermediate certificate. Leaf certificates are signed by the intermediate. They are stored in [Caddy's data directory](/docs/conventions#data-directory) at `pki/authorities/local`.
126128

127129
Caddy's local CA is powered by [Smallstep libraries](https://smallstep.com/certificates/).

src/docs/markdown/caddyfile/concepts.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Key points:
2727
- An optional [**global options block**](#global-options) can be the very first thing in the file.
2828
- Otherwise, the first line of the Caddyfile is **always** the [address(es)](#addresses) of the site to serve.
2929
- All [directives](#directives) and [matchers](#matchers) **must** go in a site block. There is no global scope or inheritence across site blocks.
30-
- If there is **only one site block**, its curly braces `{ }` are optional.
30+
- If there is only one site block, its curly braces `{ }` are optional.
3131

3232
A Caddyfile consists of at least one or more site blocks, which always starts with one or more [addresses](#addresses) for the site. Any directives appearing before the address will be confusing to the parser.
3333

@@ -41,7 +41,7 @@ Opening and closing a **block** is done with curly braces:
4141
}
4242
```
4343

44-
- The open curly brace `{` must be at the end of its line.
44+
- The open curly brace `{` must be at the end of its line and preceded by a space.
4545
- The close curly brace `}` must be on its own line.
4646

4747
When there is only one site block, the curly braces (and indentation) are optional. This is for convenience to quickly define a single site, for example, this:
@@ -82,7 +82,7 @@ If a request matches multiple site blocks, the site block with the most specific
8282

8383
### Directives
8484

85-
[**Directives**](/docs/caddyfile/directives) are keywords which customize how the site is served. For example, a complete file server config might look like this:
85+
[**Directives**](/docs/caddyfile/directives) are functional keywords which customize how the site is served. They **must** appear within site blocks. For example, a complete file server config might look like this:
8686

8787
```caddy
8888
localhost
@@ -102,9 +102,7 @@ In these examples, [`file_server`](/docs/caddyfile/directives/file_server) and [
102102

103103
In the second example, `localhost:9000` is an **argument** because it appears on the same line after the directive.
104104

105-
Note that when the Caddyfile is adapted, directives are sorted according to a specific default [directive order](/docs/caddyfile/directives#directive-order).
106-
107-
**Subdirectives** can appear in directive blocks:
105+
Sometimes directives can open their own blocks. **Subdirectives** appear on the beginning of each line within directive blocks:
108106

109107
```caddy
110108
localhost
@@ -116,6 +114,10 @@ reverse_proxy localhost:9000 localhost:9001 {
116114

117115
Here, `lb_policy` is a subdirective to [`reverse_proxy`](/docs/caddyfile/directives/reverse_proxy) (it sets the load balancing policy to use between backends).
118116

117+
**Unless otherwise documented, directives cannot be used within other directive blocks.** For example, `basicauth` cannot be used within `file_server` because the file server does not know how to do authentication; but you can use directives within [`route`](/docs/caddyfile/directives/route), [`handle`](/docs/caddyfile/directives/handle), and [`handle_path`](/docs/caddyfile/directives/handle_path) blocks because they are specifically designed to group directives together.
118+
119+
Note that when the HTTP Caddyfile is adapted, HTTP handler directives are sorted according to a specific default [directive order](/docs/caddyfile/directives#directive-order) unless in a [`route`](/docs/caddyfile/directives/route) block, so the order of appearance of the directives does not matter except in `route` blocks.
120+
119121

120122
### Tokens and quotes
121123

@@ -141,17 +143,17 @@ Quotes can be escaped if you need to use quotes in quoted tokens, too:
141143
directive "\"abc def\""
142144
```
143145

144-
Inside quoted tokens, all other characters are treated literally, including spaces, tabs, and newlines. Multi-line tokens are possible:
146+
To avoid escaping quotes, you can instead use backticks <code>\` \`</code> to enclose tokens; for example:
145147

146148
```caddy-d
147-
directive "first line
148-
second line"
149+
directive `{"foo": "bar"}`
149150
```
150151

151-
You can also use a backtick <code>`</code> to quote tokens; these are convenient when tokens themselves contain double quotes, e.g. JSON text:
152+
Inside quoted tokens, all other characters are treated literally, including spaces, tabs, and newlines. Multi-line tokens are thus possible:
152153

153154
```caddy-d
154-
directive `{"foo": "bar"}`
155+
directive "first line
156+
second line"
155157
```
156158

157159

@@ -208,9 +210,9 @@ By default, sites bind on all network interfaces. If you wish to override this,
208210

209211
## Matchers
210212

211-
By default, a directive that injects an HTTP handler applies to all requests (unless otherwise documented).
213+
HTTP handler directives apply to all requests by default (unless otherwise documented).
212214

213-
Request matchers can be used to classify requests by a given criteria. This concept originates in the [underlying JSON](/docs/json/apps/http/servers/routes/match/) structure, and it's important to know how to use them in the Caddyfile. With matchers, you can specify exactly which requests a certain directive applies to.
215+
[Request matchers](/docs/caddyfile/matchers) can be used to classify requests by a given criteria. This concept originates in the [underlying JSON](/docs/json/apps/http/servers/routes/match/) structure, and it's important to know how to use them in the Caddyfile. With matchers, you can specify exactly which requests a certain directive applies to.
214216

215217
For directives that support matchers, the first argument after the directive is the **matcher token**. Here are some examples:
216218

src/docs/markdown/caddyfile/directives.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ title: Caddyfile Directives
2929

3030
# Caddyfile Directives
3131

32+
Directives are functional keywords that appear within site [blocks](/docs/caddyfile/concepts#blocks). Sometimes, they may open blocks of their own which can contain _subdirectives_, but directives **cannot** be used within other directives unless noted. For example, you can't use `basicauth` inside a `file_server` block, because `file_server` does not know how to do authentication. However, you _may_ use some directives within special directive blocks like `handle` and `route` because they are specifically designed to group HTTP handler directives.
33+
3234
The following directives come standard with Caddy, and can be used in the HTTP Caddyfile:
3335

3436
<div id="directive-table">

src/docs/markdown/install.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,23 @@ Our [official packages](https://github.com/caddyserver/dist) come only with the
3333

3434
## Static binaries
3535

36+
**If installing onto a production system, we recommend using our official package for your distro if available below.**
37+
3638
1. Obtain a Caddy binary:
37-
- [**From releases on GitHub**](https://github.com/caddyserver/caddy/releases) (expand "Assets")
38-
- [**From our download page**](/download)
39-
- [**By building from source**](/docs/build) (either with `go` or `xcaddy`)
40-
2. We recommend [installing Caddy as a system service](/docs/running#manual-installation)
39+
- [from releases on GitHub](https://github.com/caddyserver/caddy/releases) (expand "Assets")
40+
- [from our download page](/download)
41+
- [by building from source](/docs/build) (either with `go` or `xcaddy`)
42+
2. [Install Caddy as a system service.](/docs/running#manual-installation) This is strongly recommended, especially for production servers.
43+
44+
Place the binary in one of your `$PATH` (or `%PATH%` on Windows) directories so you can run `caddy` without typing the full path of the executable file. (Run `echo $PATH` to see the list of directories that qualify.)
45+
46+
You can upgrade static binaries by replacing them with newer versions and restarting Caddy. The [`caddy upgrade` command](/docs/command-line#caddy-upgrade) can make this easy.
47+
4148

42-
You can upgrade static binaries by replacing them with newer versions and restarting Caddy.
4349

4450
## Debian, Ubuntu, Raspbian
4551

46-
Installing this package automatically starts and runs Caddy as a [systemd service](/docs/running#linux-service) named `caddy`. It also comes with a `caddy-api` service which is _not_ enabled by default but should be used if you primarily configure Caddy via its API instead of config files.
52+
Installing this package automatically starts and runs Caddy as a [systemd service](/docs/running#linux-service) named `caddy`. It also comes with an optional `caddy-api` service which is _not_ enabled by default, but should be used if you primarily configure Caddy via its API instead of config files.
4753

4854
**Stable releases:**
4955

src/docs/markdown/running.md

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ While Caddy can be run directly with its [command line interface](/docs/command-
99

1010
- [Linux Service](#linux-service)
1111
- [Unit Files](#unit-files)
12-
- [Using the Service](#using-the-service)
1312
- [Manual Installation](#manual-installation)
13+
- [Using the Service](#using-the-service)
1414
- [Overrides](#overrides)
1515
- [Windows Service](#windows-service)
1616
- [Docker Compose](#docker-compose)
@@ -36,35 +36,6 @@ If you need to switch between the services, you should disable and stop the prev
3636
<span class="bash">sudo systemctl enable --now caddy-api</span></code></pre>
3737

3838

39-
### Using the Service
40-
41-
If using a Caddyfile, you can edit your configuration with `nano`, `vi`, or your preferred editor:
42-
<pre><code class="cmd bash">sudo nano /etc/caddy/Caddyfile</code></pre>
43-
44-
You can place your static site files in either `/var/www/html` or `/srv`. Make sure the `caddy` user has permission to read the files.
45-
46-
To verify that the service is running:
47-
<pre><code class="cmd bash">systemctl status caddy</code></pre>
48-
The status command will also show the location of the currently running service file.
49-
50-
When running with our official service file, Caddy's output will be redirected to `journalctl`. To read your full logs and to avoid lines being truncated:
51-
<pre><code class="cmd bash">journalctl -u caddy --no-pager | less +G</code></pre>
52-
53-
If using a config file, you can gracefully reload Caddy after making any changes:
54-
<pre><code class="cmd bash">sudo systemctl reload caddy</code></pre>
55-
56-
You can stop the service with:
57-
<pre><code class="cmd bash">sudo systemctl stop caddy</code></pre>
58-
59-
<aside class="advice">
60-
Do not stop the service to change Caddy's configuration. Stopping the server will incur downtime. Use the reload command instead.
61-
</aside>
62-
63-
The Caddy process will run as the `caddy` user, which has its `$HOME` set to `/var/lib/caddy`. This means that:
64-
- The default [data storage location](/docs/conventions#data-directory) (for certificates and other state information) will be in `/var/lib/caddy/.local/share/caddy`.
65-
- The default [config storage location](/docs/conventions#configuration-directory) (for the auto-saved JSON config, primarily useful for the `caddy-api` service) will be in `/var/lib/caddy/.config/caddy`.
66-
67-
6839
### Manual Installation
6940

7041
Some [installation methods](/docs/install) automatically set up Caddy to run as a service. If you chose a method that did not, you may follow these instructions to do so:
@@ -112,6 +83,37 @@ Verify that it is running:
11283
Now you're ready to [use the service](#using-the-service)!
11384

11485

86+
87+
### Using the Service
88+
89+
If using a Caddyfile, you can edit your configuration with `nano`, `vi`, or your preferred editor:
90+
<pre><code class="cmd bash">sudo nano /etc/caddy/Caddyfile</code></pre>
91+
92+
You can place your static site files in either `/var/www/html` or `/srv`. Make sure the `caddy` user has permission to read the files.
93+
94+
To verify that the service is running:
95+
<pre><code class="cmd bash">systemctl status caddy</code></pre>
96+
The status command will also show the location of the currently running service file.
97+
98+
When running with our official service file, Caddy's output will be redirected to `journalctl`. To read your full logs and to avoid lines being truncated:
99+
<pre><code class="cmd bash">journalctl -u caddy --no-pager | less +G</code></pre>
100+
101+
If using a config file, you can gracefully reload Caddy after making any changes:
102+
<pre><code class="cmd bash">sudo systemctl reload caddy</code></pre>
103+
104+
You can stop the service with:
105+
<pre><code class="cmd bash">sudo systemctl stop caddy</code></pre>
106+
107+
<aside class="advice">
108+
Do not stop the service to change Caddy's configuration. Stopping the server will incur downtime. Use the reload command instead.
109+
</aside>
110+
111+
The Caddy process will run as the `caddy` user, which has its `$HOME` set to `/var/lib/caddy`. This means that:
112+
- The default [data storage location](/docs/conventions#data-directory) (for certificates and other state information) will be in `/var/lib/caddy/.local/share/caddy`.
113+
- The default [config storage location](/docs/conventions#configuration-directory) (for the auto-saved JSON config, primarily useful for the `caddy-api` service) will be in `/var/lib/caddy/.config/caddy`.
114+
115+
116+
115117
### Overrides
116118

117119
The best way to override aspects of the service files is with this command:

0 commit comments

Comments
 (0)