Merge branch '1.2.x'

This commit is contained in:
Andy Wilkinson
2015-06-22 13:44:42 +01:00
3 changed files with 18 additions and 0 deletions

View File

@@ -306,6 +306,11 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
*/
private String protocolHeader;
/**
* Value of the protocol header that indicates that the incoming request uses SSL.
*/
private String protocolHeaderHttpsValue = "https";
/**
* Name of the HTTP header used to override the original port value.
*/
@@ -435,6 +440,14 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
this.protocolHeader = protocolHeader;
}
public String getProtocolHeaderHttpsValue() {
return this.protocolHeaderHttpsValue;
}
public void setProtocolHeaderHttpsValue(String protocolHeaderHttpsValue) {
this.protocolHeaderHttpsValue = protocolHeaderHttpsValue;
}
public String getPortHeader() {
return this.portHeader;
}
@@ -502,6 +515,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
valve.setProtocolHeader(protocolHeader);
valve.setInternalProxies(getInternalProxies());
valve.setPortHeader(getPortHeader());
valve.setProtocolHeaderHttpsValue(getProtocolHeaderHttpsValue());
factory.addContextValves(valve);
}
}

View File

@@ -192,6 +192,7 @@ public class ServerPropertiesTests {
assertThat(valve, instanceOf(RemoteIpValve.class));
RemoteIpValve remoteIpValve = (RemoteIpValve) valve;
assertEquals("x-forwarded-proto", remoteIpValve.getProtocolHeader());
assertEquals("https", remoteIpValve.getProtocolHeaderHttpsValue());
assertEquals("x-forwarded-for", remoteIpValve.getRemoteIpHeader());
String expectedInternalProxies = "10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|" // 10/8
@@ -212,6 +213,7 @@ public class ServerPropertiesTests {
map.put("server.tomcat.protocol_header", "x-my-protocol-header");
map.put("server.tomcat.internal_proxies", "192.168.0.1");
map.put("server.tomcat.port-header", "x-my-forward-port");
map.put("server.tomcat.protocol-header-https-value", "On");
bindProperties(map);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
@@ -222,6 +224,7 @@ public class ServerPropertiesTests {
assertThat(valve, instanceOf(RemoteIpValve.class));
RemoteIpValve remoteIpValve = (RemoteIpValve) valve;
assertEquals("x-my-protocol-header", remoteIpValve.getProtocolHeader());
assertEquals("On", remoteIpValve.getProtocolHeaderHttpsValue());
assertEquals("x-my-remote-ip-header", remoteIpValve.getRemoteIpHeader());
assertEquals("x-my-forward-port", remoteIpValve.getPortHeader());
assertEquals("192.168.0.1", remoteIpValve.getInternalProxies());