mirror of
https://github.com/prymitive/karma
synced 2026-05-05 03:16:51 +00:00
fix(api): proxy when upstream url has a path
Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
This commit is contained in:
committed by
Łukasz Mierzwa
parent
8e1d82ddec
commit
f585312ba4
6
proxy.go
6
proxy.go
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
@@ -45,6 +46,11 @@ func NewAlertmanagerProxy(alertmanager *alertmanager.Alertmanager) (*httputil.Re
|
||||
|
||||
// set hostname of proxied target
|
||||
req.Host = upstreamURL.Host
|
||||
|
||||
// Prepend with upstream URL path if exists
|
||||
if len(upstreamURL.Path) > 0 {
|
||||
req.URL.Path = strings.TrimSuffix(upstreamURL.Path, "/") + req.URL.Path
|
||||
}
|
||||
|
||||
log.Debugf("[%s] Proxy request for %s", alertmanager.Name, req.URL.Path)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user