Fix wss in x-forwarded-proto
This commit is contained in:
parent
efcaf64a43
commit
e22c62baba
2 changed files with 12 additions and 1 deletions
|
@ -141,7 +141,7 @@ func (x *XForwarded) rewrite(outreq *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if isWebsocketRequest(outreq) {
|
if isWebsocketRequest(outreq) {
|
||||||
if outreq.Header.Get(xForwardedProto) == "https" {
|
if outreq.Header.Get(xForwardedProto) == "https" || outreq.Header.Get(xForwardedProto) == "wss" {
|
||||||
outreq.Header.Set(xForwardedProto, "wss")
|
outreq.Header.Set(xForwardedProto, "wss")
|
||||||
} else {
|
} else {
|
||||||
outreq.Header.Set(xForwardedProto, "ws")
|
outreq.Header.Set(xForwardedProto, "ws")
|
||||||
|
|
|
@ -203,6 +203,17 @@ func TestServeHTTP(t *testing.T) {
|
||||||
xForwardedProto: "wss",
|
xForwardedProto: "wss",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "xForwardedProto with websocket and tls and already x-forwarded-proto with wss",
|
||||||
|
tls: true,
|
||||||
|
websocket: true,
|
||||||
|
incomingHeaders: map[string]string{
|
||||||
|
xForwardedProto: "wss",
|
||||||
|
},
|
||||||
|
expectedHeaders: map[string]string{
|
||||||
|
xForwardedProto: "wss",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
desc: "xForwardedPort with explicit port",
|
desc: "xForwardedPort with explicit port",
|
||||||
host: "foo.com:8080",
|
host: "foo.com:8080",
|
||||||
|
|
Loading…
Reference in a new issue