Handle comma separated X-Forwarded-Proto
Adjust test to match changes for X-Forwarded-Proto
@@ -595,13 +595,13 @@ var _ = Describe("Compile", func() {
<% end %>
`)
forceHTTPSConf := stripStartWsp(`
- if ($http_x_forwarded_proto != "https") {
+ if ($best_proto != "https") {
return 301 https://$best_host$best_prefix$request_uri;
}
`)
forceHTTPSErb := stripStartWsp(`
<% if ENV["FORCE_HTTPS"] %>
- if ($http_x_forwarded_proto != "https") {
+ if ($best_proto != "https") {
return 301 https://$best_host$best_prefix$request_uri;
}
<% end %>
@@ -618,6 +618,12 @@ var _ = Describe("Compile", func() {
'' '';
}
`)
+ xForwardedProtoMappingConf := stripStartWsp(`
+ map $http_x_forwarded_proto $best_proto {
+ "~^([^,]+),?.*$" $1;
+ '' '';
+ }
+ `)
basicAuthConf := stripStartWsp(`
auth_basic "Restricted"; #For Basic Auth
auth_basic_user_file <%= ENV["APP_ROOT"] %>/nginx/conf/.htpasswd;
@@ -808,6 +814,7 @@ var _ = Describe("Compile", func() {
Expect(string(data)).To(ContainSubstring(forceHTTPSConf))
Expect(string(data)).To(ContainSubstring(xForwardedHostMappingConf))
Expect(string(data)).To(ContainSubstring(xForwardedPrefixMappingConf))
+ Expect(string(data)).To(ContainSubstring(xForwardedProtoMappingConf))
Expect(string(data)).NotTo(ContainSubstring(`<% if ENV["FORCE_HTTPS"] %>`))
})
})
@@ -821,6 +828,7 @@ var _ = Describe("Compile", func() {
Expect(string(data)).To(ContainSubstring(forceHTTPSErb))
Expect(string(data)).To(ContainSubstring(xForwardedHostMappingConf))
Expect(string(data)).To(ContainSubstring(xForwardedPrefixMappingConf))
+ Expect(string(data)).To(ContainSubstring(xForwardedProtoMappingConf))
Expect(string(data)).To(ContainSubstring(`<% if ENV["FORCE_HTTPS"] %>`))
})
})
