Update docs; commit setcap.sh

This commit is contained in:
Matthew Holt 2021-02-24 11:55:56 -07:00
parent 427bbe99d0
commit b54fa41239
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5
4 changed files with 9 additions and 12 deletions

1
.gitignore vendored
View File

@ -10,7 +10,6 @@ Caddyfile
# build artifacts and helpers # build artifacts and helpers
cmd/caddy/caddy cmd/caddy/caddy
cmd/caddy/caddy.exe cmd/caddy/caddy.exe
cmd/caddy/setcap*
# mac specific # mac specific
.DS_Store .DS_Store

View File

@ -69,7 +69,7 @@
The simplest, cross-platform way is to download from [GitHub Releases](https://github.com/caddyserver/caddy/releases) and place the executable file in your PATH. The simplest, cross-platform way is to download from [GitHub Releases](https://github.com/caddyserver/caddy/releases) and place the executable file in your PATH.
For other install options, see https://caddyserver.com/docs/download. For other install options, see https://caddyserver.com/docs/install.
## Build from source ## Build from source
@ -89,15 +89,7 @@ $ go build
When you run Caddy, it may try to bind to low ports unless otherwise specified in your config. If your OS requires elevated privileges for this, you will need to give your new binary permission to do so. On Linux, this can be done easily with: `sudo setcap cap_net_bind_service=+ep ./caddy` When you run Caddy, it may try to bind to low ports unless otherwise specified in your config. If your OS requires elevated privileges for this, you will need to give your new binary permission to do so. On Linux, this can be done easily with: `sudo setcap cap_net_bind_service=+ep ./caddy`
If you prefer to use `go run` which creates temporary binaries, you can still do this. Make an executable file called `setcap.sh` (or whatever you want) with these contents: If you prefer to use `go run` which only creates temporary binaries, you can still do this with the included `setcap.sh` like so:
```bash
#!/bin/sh
sudo setcap cap_net_bind_service=+ep "$1"
"$@"
```
then you can use `go run` like so:
```bash ```bash
$ go run -exec ./setcap.sh main.go $ go run -exec ./setcap.sh main.go

View File

@ -289,7 +289,7 @@ func unsyncedDecodeAndRun(cfgJSON []byte, allowPersist bool) error {
} else { } else {
err := ioutil.WriteFile(ConfigAutosavePath, cfgJSON, 0600) err := ioutil.WriteFile(ConfigAutosavePath, cfgJSON, 0600)
if err == nil { if err == nil {
Log().Info("autosaved config", zap.String("file", ConfigAutosavePath)) Log().Info("autosaved config (load with --resume flag)", zap.String("file", ConfigAutosavePath))
} else { } else {
Log().Error("unable to autosave config", Log().Error("unable to autosave config",
zap.String("file", ConfigAutosavePath), zap.String("file", ConfigAutosavePath),

6
cmd/caddy/setcap.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
# USAGE: go run -exec ./setcap.sh <args...>
sudo setcap cap_net_bind_service=+ep "$1"
"$@"