You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 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
Copy file name to clipboardExpand all lines: src/docs/markdown/automatic-https.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,6 +122,8 @@ In addition, hostnames qualify for publicly-trusted certificates if they:
122
122
123
123
## Local HTTPS
124
124
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
+
125
127
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`.
126
128
127
129
Caddy's local CA is powered by [Smallstep libraries](https://smallstep.com/certificates/).
Copy file name to clipboardExpand all lines: src/docs/markdown/caddyfile/concepts.md
+15-13Lines changed: 15 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ Key points:
27
27
- An optional [**global options block**](#global-options) can be the very first thing in the file.
28
28
- Otherwise, the first line of the Caddyfile is **always** the [address(es)](#addresses) of the site to serve.
29
29
- 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.
31
31
32
32
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.
33
33
@@ -41,7 +41,7 @@ Opening and closing a **block** is done with curly braces:
41
41
}
42
42
```
43
43
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.
45
45
- The close curly brace `}` must be on its own line.
46
46
47
47
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
82
82
83
83
### Directives
84
84
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:
86
86
87
87
```caddy
88
88
localhost
@@ -102,9 +102,7 @@ In these examples, [`file_server`](/docs/caddyfile/directives/file_server) and [
102
102
103
103
In the second example, `localhost:9000` is an **argument** because it appears on the same line after the directive.
104
104
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:
Here, `lb_policy` is a subdirective to [`reverse_proxy`](/docs/caddyfile/directives/reverse_proxy) (it sets the load balancing policy to use between backends).
118
116
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
+
119
121
120
122
### Tokens and quotes
121
123
@@ -141,17 +143,17 @@ Quotes can be escaped if you need to use quotes in quoted tokens, too:
141
143
directive "\"abc def\""
142
144
```
143
145
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:
145
147
146
148
```caddy-d
147
-
directive "first line
148
-
second line"
149
+
directive `{"foo": "bar"}`
149
150
```
150
151
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:
152
153
153
154
```caddy-d
154
-
directive `{"foo": "bar"}`
155
+
directive "first line
156
+
second line"
155
157
```
156
158
157
159
@@ -208,9 +210,9 @@ By default, sites bind on all network interfaces. If you wish to override this,
208
210
209
211
## Matchers
210
212
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).
212
214
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.
214
216
215
217
For directives that support matchers, the first argument after the directive is the **matcher token**. Here are some examples:
Copy file name to clipboardExpand all lines: src/docs/markdown/caddyfile/directives.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,8 @@ title: Caddyfile Directives
29
29
30
30
# Caddyfile Directives
31
31
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
+
32
34
The following directives come standard with Caddy, and can be used in the HTTP Caddyfile:
Copy file name to clipboardExpand all lines: src/docs/markdown/install.md
+12-6Lines changed: 12 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,17 +33,23 @@ Our [official packages](https://github.com/caddyserver/dist) come only with the
33
33
34
34
## Static binaries
35
35
36
+
**If installing onto a production system, we recommend using our official package for your distro if available below.**
37
+
36
38
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
+
41
48
42
-
You can upgrade static binaries by replacing them with newer versions and restarting Caddy.
43
49
44
50
## Debian, Ubuntu, Raspbian
45
51
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.
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><codeclass="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><codeclass="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:
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
-
68
39
### Manual Installation
69
40
70
41
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:
112
83
Now you're ready to [use the service](#using-the-service)!
113
84
114
85
86
+
87
+
### Using the Service
88
+
89
+
If using a Caddyfile, you can edit your configuration with `nano`, `vi`, or your preferred editor:
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><codeclass="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><codeclass="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:
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
+
115
117
### Overrides
116
118
117
119
The best way to override aspects of the service files is with this command:
0 commit comments