Location first attempt
This commit is contained in:
parent
c0f85ab85b
commit
901fd63c97
|
@ -180,6 +180,7 @@ type UnvalidatedIngressRule struct {
|
|||
Hostname string `json:"hostname"`
|
||||
Path string `json:"path"`
|
||||
Service string `json:"service"`
|
||||
Location string `json:"location"`
|
||||
OriginRequest OriginRequestConfig `yaml:"originRequest" json:"originRequest"`
|
||||
}
|
||||
|
||||
|
|
|
@ -244,6 +244,7 @@ func validateIngress(ingress []config.UnvalidatedIngressRule, defaults OriginReq
|
|||
Hostname: r.Hostname,
|
||||
Service: service,
|
||||
Path: pathRegexp,
|
||||
Location: r.Location,
|
||||
Config: cfg,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@ type Rule struct {
|
|||
// address.
|
||||
Service OriginService `json:"service"`
|
||||
|
||||
// Location is an optional string that can specify the Service path (overwriting the Hostname path).
|
||||
Location string `json:"location"`
|
||||
|
||||
// Configure the request cloudflared sends to this specific origin.
|
||||
Config OriginRequestConfig `json:"originRequest"`
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog"
|
||||
|
@ -78,6 +79,14 @@ func (p *Proxy) ProxyHTTP(
|
|||
}
|
||||
p.logRequest(req, logFields)
|
||||
|
||||
fmt.Println(fmt.Sprintf("before: req.URL.Path: %s", req.URL.Path))
|
||||
parts := strings.Split(req.URL.Path, "/")
|
||||
if len(parts) > 0 {
|
||||
parts[0] = rule.Location
|
||||
}
|
||||
req.URL.Path = strings.Join(parts, "/")
|
||||
fmt.Println(fmt.Sprintf("after: req.URL.Path: %s", req.URL.Path))
|
||||
|
||||
switch originProxy := rule.Service.(type) {
|
||||
case ingress.HTTPOriginProxy:
|
||||
if err := p.proxyHTTPRequest(
|
||||
|
|
Loading…
Reference in New Issue