octicon-git-branch(16/) Commit Graph

93 Commits

Author SHA1 Message Date
Francis Lavoie
65e0ddc221 core: Reloading with SIGUSR1 if config never changed via admin (#7258) 2025-09-26 16:50:15 +00:00 octicon-file-diff(16/) octicon-file-code(16/)
Francis Lavoie
39ace450de logging: Adjustments to BufferedLog to keep logs in the correct order (#7257)
* logging: Adjustments to BufferedLog to keep logs in the correct order

* Ignore lints
2025-09-15 09:29:50 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Francis Lavoie
012b4b3d40 logging: Buffer the logs before config is loaded (#7245) 2025-09-10 16:03:52 +00:00 octicon-file-diff(16/) octicon-file-code(16/)
Bobby Dhillon
19ff47a63b cmd: Allow caddy adapt to read from stdin (#7163) 2025-08-06 20:04:28 -04:00 octicon-file-diff(16/) octicon-file-code(16/)
eveneast
a76d005a94 Use maps.Copy for simpler map handling (#7009)
Signed-off-by: eveneast <qcqs@foxmail.com>
2025-05-13 15:16:47 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Matthew Holt
19876208c7 cmd: Promote undo maxProcs func to caller 2025-03-06 16:47:02 -07:00 octicon-file-diff(16/) octicon-file-code(16/)
Matthew Holt
a686f7c346 cmd: Only set memory/CPU limits on run (fix #6879) 2025-03-06 15:11:38 -07:00 octicon-file-diff(16/) octicon-file-code(16/)
Aziz Rmadi
fb72793269 cmd: Reject multiple configs for fmt command (#6717) 2024-12-04 05:43:52 -07:00 octicon-file-diff(16/) octicon-file-code(16/)
Matt Holt
c8adb1b553 cmd: Better error handling when reloading (#6601)
* caddyhttp: Limit auto-HTTPS error logs to 100 domains

* Improve error message and increase error size limit
2024-10-01 20:31:30 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Aaron Paterson
4b1a9b6cc1 core: Implement socket activation listeners (#6573)
* caddy adapt for listen_protocols

* adapt listen_socket

* allow multiple listen sockets for port ranges and readd socket fd listen logic

* readd logic to start servers according to listener protocols

* gofmt

* adapt caddytest

* gosec

* fmt and rename listen to listenWithSocket

* fmt and rename listen to listenWithSocket

* more consistent error msg

* non unix listenReusableWithSocketFile

* remove unused func

* doc comment typo

* nonosec

* commit

* doc comments

* more doc comments

* comment was misleading, cardinality did not change

* addressesWithProtocols

* update test

* fd/ and fdgram/

* rm addr

* actually write...

* i guess we doin' "skip": now

* wrong var in placeholder

* wrong var in placeholder II

* update param name in comment

* dont save nil file pointers

* windows

* key -> parsedKey

* osx

* multiple default_bind with protocols

* check for h1 and h2 listener netw
2024-09-30 10:55:03 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
WeidiDeng
9ddb78fadc cmd: ignore exec.ErrDot when starting caddy in background (#6512)
Co-authored-by: Mohammed Al Sahaf <msaa1990@gmail.com>
2024-08-12 20:26:20 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Mohammed Al Sahaf
787f6b257f chore: check against errors of io/fs instead of os (#6011)
* chore: replace `os.ErrNotExist` with `fs.ErrNotExist`

* check against permission error from `io/fs` package
2024-01-02 08:48:55 +03:00 octicon-file-diff(16/) octicon-file-code(16/)
Francis Lavoie
9c419f1e1a cmd: Fix exiting with custom status code, add caddy -v (#5874)
* Simplify variables for commands

* Add --envfile support for adapt command

* Carry custom status code for commands to os.Exit()

* cmd: add `-v` and `--version` to root caddy command

* Add `--envfile` to `caddy environ`, extract flag parsing to func

---------

Co-authored-by: Mohammed Al Sahaf <msaa1990@gmail.com>
2023-10-11 09:46:18 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Evan Van Dam
f2ab7099db cmd: Prevent overwriting existing env vars with --envfile (#5803)
Co-authored-by: Francis Lavoie <lavofr@gmail.com>
2023-09-07 02:19:24 +00:00 octicon-file-diff(16/) octicon-file-code(16/)
Jacob Gadikian
d6f86cccf5 ci: use gci linter (#5708)
* use gofmput to format code

* use gci to format imports

* reconfigure gci

* linter autofixes

* rearrange imports a little

* export GOOS=windows golangci-lint run ./... --fix
2023-08-14 09:41:15 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
pistasjis
d8135505d3 cmd: Require config for caddy validate (fix #5612) (#5614)
* Require config for caddy validate - fixes #5612

Signed-off-by: Pistasj <hi@pistasjis.net>

* Try making adjacent Caddyfile check its own function

Signed-off-by: Pistasj <hi@pistasjis.net>

* add Francis' suggestion

Co-authored-by: Francis Lavoie <lavofr@gmail.com>

* Refactor

* Fix borked commit, sigh

---------

Signed-off-by: Pistasj <hi@pistasjis.net>
Co-authored-by: Francis Lavoie <lavofr@gmail.com>
Co-authored-by: Matthew Holt <mholt@users.noreply.github.com>
2023-08-09 17:40:37 +00:00 octicon-file-diff(16/) octicon-file-code(16/)
Jacob Gadikian
b32f265eca ci: Use gofumpt to format code (#5707) 2023-08-07 19:40:31 +00:00 octicon-file-diff(16/) octicon-file-code(16/)
Emily
8d304a4566 cmd: Split unix sockets for admin endpoint addresses (#5696)
* cmd: fix cli when admin endpoint uses new unix socket permission format

Fixes a bug where the following Caddyfile

```Caddyfile
{
	admin unix/admin.sock|0660
}
```

and `caddy reload --config Caddyfile`
would throw the following error instead of reloading it:

```
INFO    using provided configuration    {"config_file": "Caddyfile", "config_adapter": ""}
Error: sending configuration to instance: performing request: Post "http://127.0.0.1/load": dial unix admin.sock|0660: connect: no such file or directory
[ERROR] exit status 1
```

---

This bug also affected `caddy start` and `caddy stop`.

* Move splitter function to internal

---------

Co-authored-by: Matthew Holt <mholt@users.noreply.github.com>
2023-08-06 00:09:16 +00:00 octicon-file-diff(16/) octicon-file-code(16/)
Matt Holt
f66493efef core: Allow loopback hosts for admin endpoint (fix #5650) (#5664) 2023-08-02 11:13:52 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Matthew Holt
508cf2aa22 cmd: Create pidfile before config load (close #5477) 2023-04-03 11:57:16 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Francis Lavoie
79de6df93d cmd: Strict unmarshal for validate (#5383) 2023-02-22 11:39:40 -07:00 octicon-file-diff(16/) octicon-file-code(16/)
Emily Lange
bf54892a73 cmd: make caddy fmt hints more clear (#5378) 2023-02-16 16:34:12 -07:00 octicon-file-diff(16/) octicon-file-code(16/)
Amis Shokoohi
94b8d56096 cmd: Add --envfile flag to validate command (#5350)
Fixes https://github.com/caddyserver/caddy/issues/5346
2023-01-31 16:27:35 -05:00 octicon-file-diff(16/) octicon-file-code(16/)
Amis Shokoohi
8c0b49bf03 cmd: fmt exit successfully after overwriting config file (#5351)
Fixes https://github.com/caddyserver/caddy/issues/5349
2023-01-31 11:24:44 -05:00 octicon-file-diff(16/) octicon-file-code(16/)
Y.Horie
5805b3ca11 cmd: caddy fmt return code is 1 if not formatted (#5297)
* cmd: Fix caddy fmt if input isn't formatted

* Fixes #5294
* return exit 1 with an error message

* cmd: Use formattingDifference for caddy fmt

* #5294
* expose caddyfile.formattingDifference
2023-01-21 21:28:37 -07:00 octicon-file-diff(16/) octicon-file-code(16/)
Matthew Holt
62b0685375 cmd: Improve error message if config missing 2022-09-14 23:24:16 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Mohammed Al Sahaf
258bc82b69 cmd: Migrate to spf13/cobra, remove single-dash arg support (#4565)
* cmd: migrate to spf13/cobra

* add `manpage` command

* limit Caddy tagline to root `help` only

* hard-code the manpage section to 8
2022-08-30 22:38:38 +00:00 octicon-file-diff(16/) octicon-file-code(16/)
Matt Holt
17ae5acaba cmd: Use newly-available version information (#4931) 2022-08-04 11:16:59 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Francis Lavoie
141872ed80 chore: Bump up to Go 1.19, minimum 1.18 (#4925) 2022-08-02 16:39:09 -04:00 octicon-file-diff(16/) octicon-file-code(16/)
Matthew Holt
07ed3e7c30 Minor docs clarification
Related to #4565
2022-07-29 16:56:02 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Francis Lavoie
abad9bc256 cmd: Fix reload with stdin (#4900) 2022-07-20 18:14:33 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Francis Lavoie
2e4c09155a cmd: Fix unix socket addresses for admin API requests (#4742)
Fixes a regression in c2327161f7
2022-04-28 08:31:59 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Francis Lavoie
3a1e0dbf47 httpcaddyfile: Deprecate paths in site addresses; use zap logs (#4728) 2022-04-25 10:12:10 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Francis Lavoie
6512832f9f cmd: Add --diff option for caddy fmt (#4695) 2022-04-12 14:49:19 -04:00 octicon-file-diff(16/) octicon-file-code(16/)
Francis Lavoie
22d8edb984 cmd: Fix defaulting admin address if empty in config, fixes reload (#4674) 2022-04-03 12:04:33 -04:00 octicon-file-diff(16/) octicon-file-code(16/)
Matthew Holt
c2327161f7 cmd: Set Origin header properly on API requests
Ref. https://caddy.community/t/bug-in-enforce-origin/15417
2022-03-19 22:51:32 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Francis Lavoie
bbad6931e3 pki: Implement API endpoints for certs and caddy trust (#4443)
* admin: Implement /pki/certificates/<id> API

* pki: Lower "skip_install_trust" log level to INFO

See https://github.com/caddyserver/caddy/issues/4058#issuecomment-976132935

It's not necessary to warn about this, because this was an option explicitly configured by the user. Still useful to log, but we don't need to be so loud about it.

* cmd: Export functions needed for PKI app, return API response to caller

* pki: Rewrite `caddy trust` command to use new admin endpoint instead

* pki: Rewrite `caddy untrust` command to support using admin endpoint

* Refactor cmd and pki packages for determining admin API endpoint
2022-03-02 11:08:36 -07:00 octicon-file-diff(16/) octicon-file-code(16/)
Matthew Holt
1a7a78a1f2 cmd: Print error if fmt overwrite fails (fix #4524) 2022-01-16 17:30:14 -07:00 octicon-file-diff(16/) octicon-file-code(16/)
Francis Lavoie
062657d0d8 caddycmd: Add --skip-standard to list-modules command, quieter output (#4386)
* caddycmd: Add --skip-standard to list-modules command, quieter output

* caddycmd: Also quiet `caddy upgrade` output, redundant information
2021-10-18 12:19:04 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
KallyDev
c48fadc4a7 Move from deprecated ioutil to os and io packages (#4364) 2021-09-29 11:17:48 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
peymaneh
9f6393c64c cmd: export CaddyVersion(), Commands() (#4316)
* cmd: Export CaddyVersion()

* cmd: Add getter Commands()
2021-09-01 18:08:02 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
M. Ángel Jimeno
9e333c39da cmd: use net.ErrClosed for matching returned error (#4289)
Implements #3805
2021-08-18 12:58:19 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Oleg
68c5c71659 cmd: New add-package and remove-package commands (#4226)
* adding package command

* add-package command name

* refactoring duplicate code

* fixed by review

* fixed by review

* remove-package command

* commands in different files, common utils

* fix add, remove, upgrade packages in 1 file

* copyright and downloadPath moved

* refactor

* downloadPath do no export

* adding/removing multiple packages

* addPackages/removePackages, comments, command-desc

* add-package, process case len(args) == 0

Co-authored-by: Francis Lavoie <lavofr@gmail.com>
2021-08-11 17:31:41 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Mohammed Al Sahaf
2aefe15686 cmd: upgrade: inherit the permissions of the original executable (#4160) 2021-05-11 16:11:27 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Jesse
e6f6d3a476 cmd: Add --envfile flag to start command (#4141)
* add envfile in start cmd

* fix commandfuncs

* fix commandfuncs

* fix cmdStart envfile from bool to string

Co-authored-by: Francis Lavoie <lavofr@gmail.com>
2021-05-02 12:38:16 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Carl George
45fb7202ac notify: Send all sd_notify signals from main caddy process (#4060)
Initial sd_notify support was added in #3963, but that sent signals from
both cmdRun and cmdReload.  This approach has two drawbacks:

- Reloads initiated via the API do not send signals.
- The signals are sent from different processes, which requires the
  `NotifyAccess=exec` directive in the unit file.

This change moves the NotifyReloading and NotifyReadiness invocations to
Load, which address both of those drawbacks.  It also adds a
complimentary NotifyStopping method which is invoked from handleStop.
All the notify methods are defined in a notify package to avoid an
import loop.
2021-04-05 14:01:20 -06:00 octicon-file-diff(16/) octicon-file-code(16/)
Matthew Holt
f6bb02b303 caddytls: Remove old asset migration code (close #3894) 2021-02-22 15:19:35 -07:00 octicon-file-diff(16/) octicon-file-code(16/)
Matthew Holt
ed678235a4 cmd: Clean up build-info and upgrade output 2021-02-15 12:07:55 -07:00 octicon-file-diff(16/) octicon-file-code(16/)
Matthew Holt
2772ede43c cmd: Add --force flag to reload command (close #4005)
Can be useful if user wants to reload manual certificates, for example.
2021-02-01 18:14:03 -07:00 octicon-file-diff(16/) octicon-file-code(16/)
Matt Holt
3366384d93 caddycmd: Add upgrade command (#3972)
Replaces the current Caddy executable with a new one from the build server. Honors custom builds, as long as plugins are registered on the Caddy website. Requires permissions to replace current executable, of course.

This is an experimental command that may get changed or removed later.
2021-01-19 18:45:49 -07:00 octicon-file-diff(16/) octicon-file-code(16/)