|
|
|
@ -147,6 +147,12 @@ public class ServerPropertiesTests {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void defaultTomcatRemoteIpValve() throws Exception {
|
|
|
|
|
Map<String, String> map = new HashMap<String, String>();
|
|
|
|
|
// Since 1.1.7 you need to specify at least the protocol and ip properties
|
|
|
|
|
map.put("server.tomcat.protocol_header", "x-forwarded-proto");
|
|
|
|
|
map.put("server.tomcat.remote_ip_header", "x-forwarded-for");
|
|
|
|
|
bindProperties(map);
|
|
|
|
|
|
|
|
|
|
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
|
|
|
|
|
this.properties.customize(container);
|
|
|
|
|
|
|
|
|
@ -171,6 +177,7 @@ public class ServerPropertiesTests {
|
|
|
|
|
map.put("server.tomcat.remote_ip_header", "x-my-remote-ip-header");
|
|
|
|
|
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");
|
|
|
|
|
bindProperties(map);
|
|
|
|
|
|
|
|
|
|
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
|
|
|
|
@ -182,6 +189,7 @@ public class ServerPropertiesTests {
|
|
|
|
|
RemoteIpValve remoteIpValve = (RemoteIpValve) valve;
|
|
|
|
|
assertEquals("x-my-protocol-header", remoteIpValve.getProtocolHeader());
|
|
|
|
|
assertEquals("x-my-remote-ip-header", remoteIpValve.getRemoteIpHeader());
|
|
|
|
|
assertEquals("x-my-forward-port", remoteIpValve.getPortHeader());
|
|
|
|
|
assertEquals("192.168.0.1", remoteIpValve.getInternalProxies());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|