Commit Graph

177 Commits

Author SHA1 Message Date
Julian Mazzitelli
280ae833d4 Set LimitNPROC=512 for systemd 2017-08-14 19:25:08 -04:00
Andreas Linz
53ae9b8521 Increase restart rate limit
The previous setting caused the service to hit a rate-limit when it was
restarted more than 5 times in 24h.
Editing the Caddyfile and restarting the service could also easily
trigger this rate limit.
One could argue that users could simply call `systemctl reset-failed
caddy` to reset the rate-limit counter, but this is counterintuitive
because most users won't know this command and are possibly unaware that
they had hit a rate-limit.

The service is now allowed to restart 10 times in 10 seconds before
hitting a rate limit.
This should be conservative enough to rate limit quickly failing
services and to allow users to edit and test their caddy configuration.

This closes #1718

Remove restart limit settings and use defaults

By default 5 restarts within 10 seconds are allowed without
encountering a restart limit hit, see  `man systemd.unit` for details.

Set Restart to on-abnormal

The table in https://www.freedesktop.org/software/systemd/man/systemd.service.html#Restart=
shows the conditions for which on-abnormal would restart the service.
It will *not* restart the service in the following cases:

- a non-zero exit status, e.g. an invalid Caddyfile
- a zero exit code (or those specified in SuccessExitStatus=) and a clean signal
    clean signals are SIGHUP, SIGINT, SIGTERM or SIGPIPE
    3536f49e8f/src/basic/exit-status.c (L205)

The service *will be restarted* in the following cases:

- a unclean signal, e.g. SIGKILL
- on start and watchdog timeout (we don't use those systemd service
constructs explicitly)
2017-08-13 16:38:19 +02:00
Dhananjay Balan
bd67ec99f0 freebsd init: typo in filename. (#1799) 2017-08-04 18:20:00 -06:00
Matthew Holt
e7f08bff38
Update changes and readme for v0.10.6 2017-07-28 12:21:09 -06:00
Matthew Holt
c06ff1cb37
Update changes and readme for version 0.10.5 2017-07-27 16:22:39 -06:00
Richard Bowden
25a596a98f freebsd init: added new functionality and enabled better logging (#1740)
* uses more of the builtin functionality for starting and stopping of the process by using command and command_args along with procname
* removed -f from daemon as this was hiding error message that were sent to stdout on startup, now writing stdout to the logfile directly

for example, this was being hidden:

“Activating privacy features.. [www.domain.com] failed to get certificate: Error presenting token: Could not find the start of authority”

it now shows up in the log

* aded “caddy_env” to allow the setting of environment variables that caddy might need, for example when setting creds for “DNS Challenge”

* added a check to ensure caddy_config_path file exists
2017-07-10 16:20:30 -06:00
Matthew Holt
dfa389c9df
Update README and CHANGES for 0.10.4 2017-06-28 16:10:30 -06:00
George Macon
f68233a1ba Configure systemd to send SIGQUIT on stop (#1702) 2017-06-24 11:15:13 -07:00
Messyidea
ee124a6d3c Update Initscripts
"$(which caddy)" is not work at startup. 
After this change, I can run "insserv -d caddy" to start caddy automatically on boot.
2017-06-04 12:18:33 +08:00
Matthew Holt
7323b14580
Minor change to readme/changes 2017-05-19 15:25:16 -06:00
Matthew Holt
1845e5cf52
Update readme and changelog for v0.10.3 2017-05-19 08:35:32 -06:00
Matthew Holt
90efff68e5
dist: Delete old build automation program
We now use the release program to assist in deploying Caddy (it is much
more integrated and automated): https://github.com/caddyserver/releaser

This older automation code can still be found in this gist:
https://gist.github.com/mholt/cb7285f4950cb93f23be0aa6050fb043
2017-05-05 18:12:41 -06:00
Matthew Holt
dfebffb1ee
Update readme and changes for version 0.10.2 2017-05-02 12:02:28 -06:00
Matthew Holt
6d9783a267
Update changelog and readme for 0.10.1. 2017-05-01 23:50:58 -06:00
AJ ONeal
aa7ecb02af update macOS launchd example (#1600)
* update to match same paths as systemd

* update to match new launchd plist

* generated from scratch with LaunchControl, flawless

Had some issues with the previous go and found LaunchControl which made it easy to generate a perfectly correct launchd conf

* Update README.md
2017-04-26 13:44:32 -06:00
emersion
52fd4f89bf dist/init: Better way to get systemd version (#1612) 2017-04-26 10:45:57 -06:00
Matthew Holt
0775f9123c
Change forum links to new domain 2017-04-23 12:51:08 -06:00
Matthew Holt
27785f7993
Update readme and changelog for v0.10 2017-04-20 11:36:40 -06:00
Luca Favatella
956266cd79 Make CADDYPATH equal across init scripts
See also https://github.com/mholt/caddy/pull/1272#issue-191256343
2017-03-28 22:04:19 +01:00
Zhiming Wang
18c93756b4
systemd README: set mode of caddy.service to 644 instead of 744 2017-03-11 22:43:54 -05:00
Matthew Holt
94e382ef0a
Version 0.9.5 2017-01-24 08:29:01 -07:00
Ben Gadbois
eee9d00255 Fix small misspellings 2017-01-10 13:09:24 -08:00
Matthew Holt
466efb7e67
Post init script guidelines 2016-12-30 11:56:37 -07:00
Matthew Holt
d98a7aad0f
Replace "magic" quotes with regular ones 2016-12-30 11:56:12 -07:00
Matthew Holt
7dc1dc1c78
Version 0.9.4 2016-12-21 13:47:30 -07:00
Matthew Holt
466269fd10
Limit the number of restarts with systemd 2016-12-12 21:58:35 -07:00
Lorenz Bischof
fea0d5ac3a Fix syntax in caddy.conf 2016-12-04 12:52:34 +01:00
Geno
7dc23b18ae Init switch from HOME to Caddy (#1272)
* INIT-systemd use CADDYPATH instatt of HOME

* INIT-upstart use CADDYPATH instatt of HOME

* INIT-upstart use CADDYPATH instatt of HOME

* INIT-upstart use CADDYPATH instatt of HOME
2016-11-23 14:12:19 -07:00
Matthew Holt
9d398adf5d
dist: Give more slack to numProcs test (was failing on Travis CI) 2016-11-20 21:50:46 -07:00
MathiasB
30337ac33f launchd service file for Mac 2016-11-18 17:58:40 +01:00
Sebastian Gumprich
f1342e37ed add separate upstart scripts for centos 6 and ubuntu 12.04 2016-10-17 22:04:26 +02:00
Tw
b48bda4a6d dist: adapt to archiver's refactor
Signed-off-by: Tw <tw19881113@gmail.com>
2016-10-10 16:39:27 +08:00
Matthew Holt
c885edda24
Version 0.9.3 2016-09-28 12:43:28 -06:00
Josh Aas
3f83eccfbd improvements for Linux systemd integration (#1127)
* Remove unnecessary config options from systemd service so it will work with earlier versions of systemd. Simplify the systemd service instructions and make them more complete.

* Minor systemd README improvements.

* Add back some of the optional systemd 229 stuff but commented out for compat.

* A bunch of updates to the README for linux systemd.
2016-09-23 16:50:39 -06:00
Matthew Holt
73916ccc30
Version 0.9.2 2016-09-20 16:33:50 -06:00
David Prandzioch
8e54d5cecb Updated FreeBSD init script (#1098)
* Updated FreeBSD init script to allow the server to stop properly

* Fixed FreeBSD init script permissions

* Updated FreeBSD init script to allow the server to stop properly
2016-09-08 21:02:28 -06:00
Matthew Holt
c5aa5843d9
Version 0.9.1 2016-08-17 14:09:04 -06:00
Daniel van Dorp
dbd76f7a57 dist/init/linux-sysvinit: process @weingart's feedback (#1008)
* dist/init/linux-sysvinit: use kill -0 to test process status

* dist/init/linux-sysvinit: use service (as root) instead of /etc/init.d/
2016-08-09 22:29:13 -06:00
Daniel van Dorp
3a4f8e8d0c dist/init/linux-sysvinit: execute setcap directly
`$(which setcap)` might evaluate to nothing,
and this way the error thrown will be more clear.
If setcap is not available on Debian/Ubuntu,
you can install the package `libcap2-bin`
2016-08-05 16:33:47 +02:00
Daniel van Dorp
f3a3bf6204 dist/init/linux-sysvinit: improve legacy compatibility (#1002)
* dist/init/linux-sysvinit: pass --oknodo for --start as well

* dist/init/linux-sysvinit: manually rm PIDFILE

Since start-stop-daemon --remove-pidfile is new and not present
everywhere.
2016-08-05 08:15:32 -06:00
Daniel van Dorp
22a4b6cde2 dist/init/linux-sysvinit: fix minor typo in DAEMONOPTS 2016-08-05 14:04:30 +02:00
Daniel van Dorp
251c38bfb2 dist/init/linux-sysvinit: caddy for SysVinit
In addition to `linux-upstart` and `linux-systemd`, I think this one
might be very useful too.

The script is based on [this script](https://git.devuan.org/fredg/stuffs/blob/master/caddy/init.d/caddy)
by @fredg, found via [Installation du serveur Caddy sous Devuan &middot; Frédéric Galusik](http://galusik.xyz/installation-caddy-server-devuan/#démon:d7570338f345f168f3c50f22e7f8c47c).
I have modified it into an extended version myself, since I had the need for this.
2016-08-01 20:51:22 +02:00
Leo
72af3f8256 Specify the reload signal in the upstart script 2016-07-29 22:56:25 +02:00
Matthew Holt
f28af63732
Version 0.9 2016-07-18 21:50:45 -06:00
Ian Walter
ad2ed5b0ae Changing refs from /usr/bin to /usr/local/bin 2016-07-05 13:39:04 -04:00
Matthew Holt
fdb6d64f9d
Add locale plugin directive, update changelog 2016-07-02 18:07:24 -06:00
Matthew Holt
b49f65d5de
0.9 beta 2 2016-06-22 07:09:27 -06:00
Matthew Holt
e585a74115
Revamped readme 2016-06-21 11:28:38 -06:00
Matthew Holt
0a3f68f0d7
Fix test on Windows (with 1 CPU) 2016-06-21 00:23:18 -06:00
Matthew Holt
e625c7c051
Every package has a test 2016-06-21 00:11:55 -06:00
Matthew Holt
6492592b4a Update change list, fix build script; version 0.9 beta 1 2016-06-07 14:33:06 -06:00
Matthew Holt
e7fc26e3fb
Improved godoc, added two missing directives, update change log 2016-06-07 09:27:14 -06:00
Matt Holt
9b4134b287 Merge pull request #866 from mholt/0.9-wip
Merge 0.9 into master (warning: huge diff)
2016-06-06 07:39:16 -06:00
Leo Koppelkamm
ddff08392a Make upstart script more fault tolerant and easier to debug (#824)
* Make Upstart script more fault tolerant and easier to debug

* update readme
2016-06-06 07:32:27 -06:00
Matthew Holt
ac4fa2c3a9
Rewrote Caddy from the ground up; initial commit of 0.9 branch
These changes span work from the last ~4 months in an effort to make
Caddy more extensible, reduce the coupling between its components, and
lay a more robust foundation of code going forward into 1.0. A bunch of
new features have been added, too, with even higher future potential.

The most significant design change is an overall inversion of
dependencies. Instead of the caddy package knowing about the server
and the notion of middleware and config, the caddy package exposes an
interface that other components plug into. This does introduce more
indirection when reading the code, but every piece is very modular and
pluggable. Even the HTTP server is pluggable.

The caddy package has been moved to the top level, and main has been
pushed into a subfolder called caddy. The actual logic of the main
file has been pushed even further into caddy/caddymain/run.go so that
custom builds of Caddy can be 'go get'able.

The HTTPS logic was surgically separated into two parts to divide the
TLS-specific code and the HTTPS-specific code. The caddytls package can
now be used by any type of server that needs TLS, not just HTTP. I also
added the ability to customize nearly every aspect of TLS at the site
level rather than all sites sharing the same TLS configuration. Not all
of this flexibility is exposed in the Caddyfile yet, but it may be in
the future. Caddy can also generate self-signed certificates in memory
for the convenience of a developer working on localhost who wants HTTPS.
And Caddy now supports the DNS challenge, assuming at least one DNS
provider is plugged in.

Dozens, if not hundreds, of other minor changes swept through the code
base as I literally started from an empty main function, copying over
functions or files as needed, then adjusting them to fit in the new
design. Most tests have been restored and adapted to the new API,
but more work is needed there.

A lot of what was "impossible" before is now possible, or can be made
possible with minimal disruption of the code. For example, it's fairly
easy to make plugins hook into another part of the code via callbacks.
Plugins can do more than just be directives; we now have plugins that
customize how the Caddyfile is loaded (useful when you need to get your
configuration from a remote store).

Site addresses no longer need be just a host and port. They can have a
path, allowing you to scope a configuration to a specific path. There is
no inheretance, however; each site configuration is distinct.

Thanks to amazing work by Lucas Clemente, this commit adds experimental
QUIC support. Turn it on using the -quic flag; your browser may have
to be configured to enable it.

Almost everything is here, but you will notice that most of the middle-
ware are missing. After those are transferred over, we'll be ready for
beta tests.

I'm very excited to get this out. Thanks for everyone's help and
patience these last few months. I hope you like it!!
2016-06-04 17:00:29 -06:00
Matthew Holt
324ec15890
Link to forum 2016-05-27 09:15:06 -06:00
W-Mark Kubacki
bee9c50a71
systemd, README: needs to be version 229 or later, and how to display logs
We have had three operators within a few days which ran into the same cause
and had not been able to figure out what went wrong.

addresses #833, #822
2016-05-21 00:54:44 +02:00
Leo Koppelkamm
4c62397ff8 fix typo 2016-05-14 16:39:00 +02:00
W-Mark Kubacki
da8ae9e511
systemd: Run caddy with even less privileges and more confined
The exemplary unit file for systemd is intentionally redundant at times, for
example dropping privileges which an unprivileged user "www-data" did not have
in the first place: To aid as fallback in case the file gets copied and an
operator setting UID to 0 (which reportedly happened in the past).
2016-05-12 15:11:43 +02:00
W-Mark Kubacki
d377c79a5d
systemd, README: Edit for clarity 2016-05-12 15:08:06 +02:00
Matthew Holt
d05dac8d2e Little bit of housekeeping 2016-04-27 12:52:00 -06:00
Matthew Holt
21382702d2
Update readme version, 0.8.3 2016-04-26 09:28:05 -06:00
Matthew Holt
e97649493b
Update change log; version 0.8.3 2016-04-26 08:36:59 -06:00
Matthew Holt
924b53eb3c Minor changes 2016-04-18 09:43:28 -06:00
Matthew Holt
b75016e646 Fix lint warning 2016-04-15 15:13:44 -06:00
Matt Holt
d3a77ce3c3 Use binExt 2016-04-13 15:21:18 -06:00
Matthew Holt
67b137175e
Replaced automate.sh with Go program 2016-04-09 10:02:16 -06:00
Matthew Holt
dfa3b8645d
Who uses 32-bit Mac anyway. :P 2016-04-09 00:40:37 -06:00
Matthew Holt
2dca50dee8
Rewrite automate.sh as Go program; add init folder to release archives
Easier parallelism and more control over platforms we build for, but
more importantly, we can do parallel builds using the build script which
properly embeds version information into the binaries. We also produce
the archive files ourselves and in parallel rather than using external
tar and zip commands.
2016-04-09 00:21:55 -06:00
Matthew Holt
86ccafbe58
Update changes
Also testing commit signing again, different email this time.
2016-04-05 19:04:08 -06:00
MathiasB
86854dca89 dist/init: caddy.conf for upstart 2016-03-31 14:36:44 +02:00
Matthew Holt
426d165254 expvar: Allow no args; publish number of goroutines 2016-03-21 22:39:57 -06:00
Matthew Holt
b6e5a599fb Update change log 2016-03-21 12:36:27 -06:00
Matthew Holt
27f9b58c5d Bypass "bandwidth limit exceeded" errors when cloning from googlesource
cf. golang/go#12933
2016-03-21 12:05:16 -06:00
Matthew Holt
f23d8cb37f Add {upstream} placeholder when proxy middleware is used (closes #531)
Middlewares can now make their own placeholders that may be useful in
logging, on a per-request basis. Proxy is the first one to do this.
2016-03-20 21:56:13 -06:00
Matthew Holt
3f49b32086 Revert undesired changes to shell scripts 2016-03-20 14:13:50 -06:00
Matt Holt
0aacaea918 Merge pull request #686 from wmark/for-mholt
Reflow all bash scripts
2016-03-20 14:04:44 -06:00
Matthew Holt
4d9741dda6 pprof: Only handle if path matches /debug/pprof, add tests 2016-03-19 20:02:05 -06:00
W-Mark Kubacki
74a5cb2fe3 Convert the barbarism in dist/automate.sh to proper BASH structure
When thy variables henceforth accept blessed white-space,
    guided will thy scripture be along righteous path(s).

    -- 4 BASH 3:42

Caddy's dist files sometimes ended up being owned by matt:staff or other
quite arcane and/or frightening names. If someone extracting didn't pay
attention a regular user who happened to have same uid by accident could
later tamper with the files' contents. It's 0:0 from now on.

Use all available threads when packaging distributables
Caddy binaries will be added to their archives in-place: This change
eliminates them being renamed within dist/builds one after another.
As does 'gox', dist/automate.sh will spare one available thread if possible.
2016-03-20 01:33:58 +01:00
W-Mark Kubacki
f1c1ea9905 Service file for systemd starts after all networks have gotten IP addresses
Unlike network.target the network-online.target guarantees that the network
devices are online.

If you bind to 0.0.0.0, [::], [::1], and/or 127.0.0.1 only that is enough to
proceed. But in case a particular IP is needed, like ${COREOS_PUBLIC_IPV4},
we require any IP assignments to have completed before Caddy's start. That
is achieved by depending on systemd-networkd-wait-online.service (which is
scheduled before network-online.target, then, automatically).
2016-03-18 12:36:54 +01:00
Matt Holt
03a22aeb7e Merge pull request #683 from klingtnet/feat/systemd
systemd unit file
2016-03-17 21:05:12 -06:00
Matthew Holt
37d050922b Fix typo, clarify readme 2016-03-17 16:42:28 -06:00
Andreas Linz
6c2bf36dab Add systemd unit file and some usage instructions
Add systemd service file for caddy

Add some README with basic setup instructions

Explain how to view the service configuration

Add a note about permissions

Add a comment about run user and group

service->service unit

A systemd service can consist of different units. A unit configuration
file has the `.service` file ending which is a bit confusing, so please
be considerate if I'm confusing `service` and `unit` in the README

Fix typos/reword

Add contact information
2016-03-17 17:39:50 +01:00
Matthew Holt
4f4b34d481 Update changelog 2016-03-16 11:46:10 -06:00
David Prandzioch
202679efde Renamed apache24 occurance to caddy :-) 2016-03-06 10:49:29 +01:00
David Prandzioch
75915e0a25 Added a directory dist/init/ that may provide service scripts for various distributions in the future, added a experimental FreeBSD service script 2016-03-06 10:44:07 +01:00
Matthew Holt
c827a71d5d Version 0.8.2 2016-02-25 10:26:42 -07:00
Matthew Holt
ecf913e58d Update change log 2016-02-18 20:57:38 -07:00
jungle-boogie
73ed286309 wrap lines to 80
also update copyright year.
2016-01-27 11:28:49 -08:00
Matthew Holt
7613ae3bf0 Change to Windows line endings for poor Notepad 2016-01-25 13:46:07 -07:00
Matthew Holt
3c96718027 Version 0.8.1 2016-01-12 10:01:57 -07:00
Matthew Holt
97c8c9582a Updated changelog 2016-01-10 21:52:56 -07:00
Matthew Holt
5b93799a62 Version 0.8.0 2015-12-03 19:52:15 -07:00
Matthew Holt
19c6bbf6a2 Update changelist (env vars) 2015-12-02 11:42:50 -07:00
Matthew Holt
4d907d57fa Whoops, emergency bug fix
Made a faulty assumption that virualhosts could share acme proxy handlers; turns out they can't without fumbling up the middleware configuration (middleware chains overlap and cross over into other virtualhosts)!
2015-11-18 18:41:01 -07:00
Matthew Holt
a2ba00bdc8 Update docs n things 2015-11-17 10:19:03 -07:00
Matthew Holt
7d5b6b96ea Make signal trapping optional
Go programs using the caddy package may not want the it to capture all the signals...
2015-11-14 21:59:43 -07:00
Matthew Holt
b42334eb91 Several improvements and bug fixes related to graceful reloads
Added a -grace flag to customize graceful shutdown period, fixed bugs related to closing file descriptors (and dup'ed fds), improved healthcheck signaling to parent, fixed a race condition with the graceful listener, etc. These improvements mainly provide better support for frequent reloading or unusual use cases of Start and Stop after a Restart (POSIX systems). This forum thread was valuable help in debugging: https://forum.golangbridge.org/t/bind-address-already-in-use-even-after-listener-closed/1510?u=matt
2015-11-14 18:00:25 -07:00
Matthew Holt
8628a50b7d Forgot this one 2015-11-07 17:25:44 -07:00
Matthew Holt
bcea5182c6 Don't truncate process log; more consistent output 2015-11-05 17:01:08 -07:00