* Use syslog to manage caddy std{out,err} on FreeBSD
There is no good way to rotate the logfile created by the previous
FreeBSD rc.d script (it's the result of redirecting std{out,err} and
is held open by the shell).
This solves the problem by sending caddy's std{out,err} stream to
syslog, using the daemon command's builtin functionality.
It replaces the old `caddy_logfile` rc.conf variable with
`caddy_syslog_facility` (which defaults to 'local7') and
`caddy_syslog_level` (which defaults to 'notice').
By default, these messages will end up in /var/log/messages but can
be redirected as documented in the script's comments.
* Add info about rotating log with newsyslog
If you create a caddy specific logfile in `/var/log`, you should
rotate it.
This adds a bit of info to the dist/init/freebsd/README.md about
rotating that log file with newsyslog.
Currently, the instance waitgroup is decremented twice in `startServers()`: once when `Serve()` is finished and once when `ServePacket()` is finished. However, with a graceful shutdown, `Serve()` returns before the server has actually finished shutting down all active connections. This patch increases the wait group by one when the server is shut down so that the program only exits when all the server instances have finished serving their connections.
A random config is intended to be used only for solving TLS-ALPN
challenges; so we have to be sure to disable on-demand TLS so that
arbitrary names can't request certificates with another name's
on-demand config.
Slightly inconvenient because it uses int type and we use string, but
oh well. This fixes a bug related to setting -http-port and -https-port
flags which weren't being used by CertMagic in some cases.
This should help prevent hanging in some cases when the process is
restarted and tries to obtain or renew a certificate, for example, but
the lock remains from the previous shutdown (which was during the same
operation). Only works if the process is cleanly shut down with a signal
it can capture.
Each time the Caddyfile reloads and Caddy is restarted,
caddytls.NewConfig starts a goroutine for cleaning the
certificate storage. This goroutine ranges over a time.Ticker
channel; although Stop is called on this ticker, Stop does
not close the underlying channel so the goroutine never exits.
This change adds an additional channel that is listened to
in the certificate cleaning goroutine so it can exit
on restarts.
* More informative rewrite test output
When running rewrite tests, the output in case of a test failure now
includes not only the rewritten URLs but also the from URL.
* Move re-escaping to regexpMatches
This commit moves the code to post-process the match replacements from
ComplexRule to regexpMatches, so it can later be re-used for SimpleRule.
Also changes the comment in an attempt to better explain the reasoning
behind that code.
The required strings.Replacer is now built only once.
* Support regex captures in simple rewrite rules
Closes#2586
Caddy can be built, even with plugins, without modifying the source
code and without special build scripts, thanks to Go modules. See
the README or wiki.
* Set up CI with Azure Pipelines [skip ci]
* Add other platforms [skip ci]
* Oops, add vmImage back in [skip ci]
* Fix goVersion [skip ci]
* Use sudo to install Go [skip ci]
* Attempt platform-specific Go isntalls [skip ci]
* Try sharing the variable a different way [skip ci]
* Trying this again... [skip ci]
* Fix the PATH [skip ci]
* Fix GOROOT, hopefully [skip ci]
* More fixing [skip ci]
* Still fixing [skip ci]
* Add golang-ci [skip ci]
* asdfasdfasf [skip ci]
* Sigh, work around broken golangci-lint installer [skip ci]
* Try again [skip ci]
* ahhhhhh [skip ci]
* sooooo close! cleanup [skip ci]
* oh c'mon [skip ci]
* thought I had it for a sec [skip ci]
* yaaaayyyy [skip ci]
ship it