Update for beta 17

This commit is contained in:
Matthew Holt 2020-03-14 10:38:42 -06:00
parent a0d5e5097c
commit 5cf7dc8c93
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
14 changed files with 154 additions and 61 deletions

View file

@ -24,9 +24,15 @@ Save this and run Caddy from the same folder that contains your Caddyfile:
<pre><code class="cmd bash">caddy start</code></pre>
Either open your browser to [localhost:2015](http://localhost:2015) or `curl` it:
<aside class="tip">
For local HTTPS, Caddy automatically generates certificates and unique private keys for you. The root certificate is added to your system's trust store, which is why the password prompt is necessary. It allows you to develop locally over HTTPS without certificate errors. Just don't share your root key!
</aside>
<pre><code class="cmd"><span class="bash">curl localhost:2015</span>
You will probably be asked for your password, because Caddy will serve all sites -- even local ones -- over HTTPS. (The password prompt should only happen the first time!)
Either open your browser to [localhost](http://localhost) or `curl` it:
<pre><code class="cmd"><span class="bash">curl https://localhost</span>
Hello, world!</code></pre>
You can define multiple sites in a Caddyfile by wrapping them in curly braces `{ }`. Change your Caddyfile to be:
@ -44,18 +50,18 @@ localhost:2016 {
You can give Caddy the updated configuration two ways, either with the API directly:
<pre><code class="cmd bash">curl localhost:2019/load \
-X POST \
-H "Content-Type: text/caddyfile" \
--data-binary @Caddyfile
-X POST \
-H "Content-Type: text/caddyfile" \
--data-binary @Caddyfile
</code></pre>
or with the reload command, which does the same API request for you:
<pre><code class="cmd bash">caddy reload</code></pre>
Try out your new "goodbye" endpoint [in your browser](http://localhost:2016) or with `curl` to make sure it works:
Try out your new "goodbye" endpoint [in your browser](https://localhost:2016) or with `curl` to make sure it works:
<pre><code class="cmd"><span class="bash">curl localhost:2016</span>
<pre><code class="cmd"><span class="bash">curl https://localhost:2016</span>
Goodbye, world!</code></pre>
When you are done with Caddy, make sure to stop it:

View file

@ -21,17 +21,17 @@ In your terminal, change to the root directory of your site and run:
<pre><code class="cmd bash">caddy file-server</code></pre>
The default address is :2015, so load [localhost:2015](http://localhost:2015) in your browser to see your site!
If you get a permission error, it probably means your OS does not allow you to bind to low ports -- so use a high port instead:
<pre><code class="cmd bash">caddy file-server --listen :2015</code></pre>
Then open [localhost](http://localhost) (or [localhost:2015](http://localhost:2015)) in your browser to see your site!
If you don't have an index file but you want to display a file listing, use the `--browse` option:
<pre><code class="cmd bash">caddy file-server --browse</code></pre>
You can also listen on port 80 easily enough:
<pre><code class="cmd bash">caddy file-server --listen :80</code></pre>
Or set use another folder as the site root:
You can use another folder as the site root:
<pre><code class="cmd bash">caddy file-server --root ~/mysite</code></pre>
@ -47,11 +47,13 @@ localhost
file_server
```
If you don't have permission to bind to low ports, replace `localhost` with `localhost:2015` (or some other high port).
Then, from the same directory, run:
<pre><code class="cmd bash">caddy run</code></pre>
You can then load [localhost:2015](http://localhost:2015) to see your site!
You can then load [localhost](https://localhost) (or whatever the address in your config is) to see your site!
The [`file_server` directive](/docs/caddyfile/directives/file_server) has more options for you to customize your site. Make sure to [reload](/docs/command-line#caddy-reload) Caddy (or stop and start it again) when you change the Caddyfile!
@ -63,15 +65,7 @@ localhost
file_server browse
```
You can also listen on port 80 easily enough:
```
:80
file_server
```
Or set use another folder as the site root:
You can also use another folder as the site root:
```
localhost

View file

@ -24,13 +24,11 @@ In your terminal, run this command:
<pre><code class="cmd bash">caddy reverse-proxy --to 127.0.0.1:9000</code></pre>
Caddy's default address is :2015, so make a request to [localhost:2015](http://localhost:2015) to see it working!
It's easy to change the proxy's address:
If you don't have permission to bind to low ports, you can proxy from a higher port:
<pre><code class="cmd bash">caddy reverse-proxy --from :2016 --to 127.0.0.1:9000</code></pre>
Now you can access the proxy at [localhost:2016](http://localhost:2016).
Then make a request to [localhost](https://localhost) (or whatever address you specified in `--from`) to see it working!
@ -48,7 +46,7 @@ Then, from the same directory, run:
<pre><code class="cmd bash">caddy run</code></pre>
You can then make a request to [localhost:2015](http://localhost:2015) to see it working!
You can then make a request to [https://localhost](https://localhost) to see it working!
It's easy to change the proxy's address: