@@ -25,7 +25,7 @@ func TestSchemeHost(t *testing.T) {
25
25
},
26
26
},
27
27
expectedScheme : "https" ,
28
- expectedHost : "example.com:443 " ,
28
+ expectedHost : "example.com" ,
29
29
},
30
30
"X-Forwarded-Port overwrites X-Forwarded-Host port" : {
31
31
req : & http.Request {
@@ -51,7 +51,32 @@ func TestSchemeHost(t *testing.T) {
51
51
},
52
52
},
53
53
expectedScheme : "https" ,
54
- expectedHost : "example.com:443" ,
54
+ expectedHost : "example.com" ,
55
+ },
56
+ "stripped X-Forwarded-Host and X-Forwarded-Port with non-standard port" : {
57
+ req : & http.Request {
58
+ URL : & url.URL {Path : "/" },
59
+ Host : "127.0.0.1" ,
60
+ Header : http.Header {
61
+ "X-Forwarded-Host" : []string {"example.com" },
62
+ "X-Forwarded-Port" : []string {"80" },
63
+ "X-Forwarded-Proto" : []string {"https" },
64
+ },
65
+ },
66
+ expectedScheme : "https" ,
67
+ expectedHost : "example.com:80" ,
68
+ },
69
+ "detect scheme from X-Forwarded-Port" : {
70
+ req : & http.Request {
71
+ URL : & url.URL {Path : "/" },
72
+ Host : "127.0.0.1" ,
73
+ Header : http.Header {
74
+ "X-Forwarded-Host" : []string {"example.com" },
75
+ "X-Forwarded-Port" : []string {"443" },
76
+ },
77
+ },
78
+ expectedScheme : "https" ,
79
+ expectedHost : "example.com" ,
55
80
},
56
81
57
82
"req host" : {
@@ -156,7 +181,7 @@ func TestSchemeHost(t *testing.T) {
156
181
},
157
182
},
158
183
expectedScheme : "http" ,
159
- expectedHost : "route-namespace.router.default.svc.cluster.local:80 " ,
184
+ expectedHost : "route-namespace.router.default.svc.cluster.local" ,
160
185
},
161
186
"haproxy edge terminated route -> svc -> non-tls pod" : {
162
187
req : & http.Request {
@@ -171,6 +196,21 @@ func TestSchemeHost(t *testing.T) {
171
196
},
172
197
},
173
198
expectedScheme : "https" ,
199
+ expectedHost : "route-namespace.router.default.svc.cluster.local" ,
200
+ },
201
+ "haproxy edge terminated route -> svc -> non-tls pod with the explicit port" : {
202
+ req : & http.Request {
203
+ URL : & url.URL {Path : "/" },
204
+ Host : "route-namespace.router.default.svc.cluster.local:443" ,
205
+ Header : http.Header {
206
+ "X-Forwarded-Host" : []string {"route-namespace.router.default.svc.cluster.local:443" },
207
+ "X-Forwarded-Port" : []string {"443" },
208
+ "X-Forwarded-Proto" : []string {"https" },
209
+ "Forwarded" : []string {"for=172.18.2.57;host=route-namespace.router.default.svc.cluster.local:443;proto=https" },
210
+ "X-Forwarded-For" : []string {"172.18.2.57" },
211
+ },
212
+ },
213
+ expectedScheme : "https" ,
174
214
expectedHost : "route-namespace.router.default.svc.cluster.local:443" ,
175
215
},
176
216
"haproxy passthrough route -> svc -> tls pod" : {
0 commit comments