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
* Add upstream header replacements (TODO: tests, docs)
* Add tests, fix a few bugs
* Add more tests and comments
* Refactor header_upstream to use a fallthrough; return regex errors