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