Setup Spring Boot zuul reverse proxy for Splunk
When using Splunk in enterprise environment, you often need to access it via some sort of proxy. I have considered nginx / zuul. However, I don’t have either a physical server nor virtual server, PCF is the only option.
While you don’t have much option with nginx on PCF, the only choice seems to be zuul. The configuration really simple but require a bit hack on it.
First you create a Spring boot application with spring-cloud-starter-zuul.
Second you enable it with @EnableZuulProxy
Last trick you ignore zuul ignoredHeaders cookie and set-cookie
@SpringBootApplication
@EnableZuulProxy
public class ZuulProxyApplication {
public static void main(String[] args) {
SpringApplication.run(ZuulProxyApplication.class, args);
}
}
@Component
class TokenRelayFilter extends ZuulFilter {
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
Set<String> headers = (Set<String>) ctx.get("ignoredHeaders");
headers.remove("cookie");
headers.remove("set-cookie");
return null;
}
@Override
public String filterType() {
return "pre";
}
@Override
public int filterOrder() {
return 10000;
}
@Override
public boolean shouldFilter() {
return true;
}
}in you application.properties
zuul.routes.splunk.url=http://192.168.1.110:8000/
zuul.routes.splunk.path=/**Assumed you deployed application URL is
You login via http://splunk.dev.local/en-US/account/login, after login successfully you shall see an blank page(no idea why)
then you put http://splunk.dev.local/en-US/app/search/search
done.