mirror of
https://github.com/caddyserver/caddy.git
synced 2025-02-03 23:09:57 -05:00
Merge branch '2.4'
This commit is contained in:
commit
c052162203
6 changed files with 27 additions and 3 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -6,9 +6,11 @@ on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- 2.*
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- 2.*
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
|
|
2
.github/workflows/cross-build.yml
vendored
2
.github/workflows/cross-build.yml
vendored
|
@ -4,9 +4,11 @@ on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- 2.*
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- 2.*
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
cross-build-test:
|
cross-build-test:
|
||||||
|
|
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
|
@ -4,9 +4,11 @@ on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- 2.*
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- 2.*
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# From https://github.com/golangci/golangci-lint-action
|
# From https://github.com/golangci/golangci-lint-action
|
||||||
|
|
|
@ -214,6 +214,11 @@ func (p *parser) addresses() error {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Users commonly forget to place a space between the address and the '{'
|
||||||
|
if strings.HasSuffix(tkn, "{") {
|
||||||
|
return p.Errf("Site addresses cannot end with a curly brace: '%s' - put a space between the token and the brace", tkn)
|
||||||
|
}
|
||||||
|
|
||||||
if tkn != "" { // empty token possible if user typed ""
|
if tkn != "" { // empty token possible if user typed ""
|
||||||
// Trailing comma indicates another address will follow, which
|
// Trailing comma indicates another address will follow, which
|
||||||
// may possibly be on the next line
|
// may possibly be on the next line
|
||||||
|
|
|
@ -160,6 +160,10 @@ func TestParseOneAndImport(t *testing.T) {
|
||||||
"localhost",
|
"localhost",
|
||||||
}, []int{}},
|
}, []int{}},
|
||||||
|
|
||||||
|
{`localhost{
|
||||||
|
dir1
|
||||||
|
}`, true, []string{}, []int{}},
|
||||||
|
|
||||||
{`localhost
|
{`localhost
|
||||||
dir1 {
|
dir1 {
|
||||||
nested {
|
nested {
|
||||||
|
|
|
@ -120,9 +120,10 @@ type Handler struct {
|
||||||
// handler chain will not affect the health status of the
|
// handler chain will not affect the health status of the
|
||||||
// backend.
|
// backend.
|
||||||
//
|
//
|
||||||
// Two new placeholders are available in this handler chain:
|
// Three new placeholders are available in this handler chain:
|
||||||
// - `{http.reverse_proxy.status_code}` The status code
|
// - `{http.reverse_proxy.status_code}` The status code from the response
|
||||||
// - `{http.reverse_proxy.status_text}` The status text
|
// - `{http.reverse_proxy.status_text}` The status text from the response
|
||||||
|
// - `{http.reverse_proxy.header.*}` The headers from the response
|
||||||
HandleResponse []caddyhttp.ResponseHandler `json:"handle_response,omitempty"`
|
HandleResponse []caddyhttp.ResponseHandler `json:"handle_response,omitempty"`
|
||||||
|
|
||||||
Transport http.RoundTripper `json:"-"`
|
Transport http.RoundTripper `json:"-"`
|
||||||
|
@ -631,9 +632,17 @@ func (h *Handler) reverseProxy(rw http.ResponseWriter, req *http.Request, repl *
|
||||||
if len(rh.Routes) == 0 {
|
if len(rh.Routes) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
|
|
||||||
|
// set up the replacer so that parts of the original response can be
|
||||||
|
// used for routing decisions
|
||||||
|
for field, value := range res.Header {
|
||||||
|
repl.Set("http.reverse_proxy.header."+field, strings.Join(value, ","))
|
||||||
|
}
|
||||||
repl.Set("http.reverse_proxy.status_code", res.StatusCode)
|
repl.Set("http.reverse_proxy.status_code", res.StatusCode)
|
||||||
repl.Set("http.reverse_proxy.status_text", res.Status)
|
repl.Set("http.reverse_proxy.status_text", res.Status)
|
||||||
|
|
||||||
h.logger.Debug("handling response", zap.Int("handler", i))
|
h.logger.Debug("handling response", zap.Int("handler", i))
|
||||||
if routeErr := rh.Routes.Compile(next).ServeHTTP(rw, req); routeErr != nil {
|
if routeErr := rh.Routes.Compile(next).ServeHTTP(rw, req); routeErr != nil {
|
||||||
// wrap error in roundtripSucceeded so caller knows that
|
// wrap error in roundtripSucceeded so caller knows that
|
||||||
|
|
Loading…
Add table
Reference in a new issue