Installing the Java Module as a Netty Handler
Last updated 2023-01-20
IMPORTANT
This guide only applies to Next-Gen WAF customers with access to the Next-Gen WAF control panel. If you have access to the Next-Gen WAF product in the Fastly control panel, you can only deploy the Next-Gen WAF with the Edge WAF deployment method.
The Next-Gen WAF Netty module is implemented as a handler which inspects HttpRequest
events before forwarding the event to the next handler in the pipeline.
Download
Download the Next-Gen WAF Java module manually or access it with Maven.
Download manually
- Download the Java module archive from https://dl.signalsciences.net/sigsci-module-java/sigsci-module-java_latest.tar.gz.
- Extract
sigsci-module-java_latest.tar.gz
. - Deploy the jars using one of the following options:
- Copy
sigsci-module-java-{version}-shaded.jar
(an uber jar with all the dependencies bundled) to your application’s classpath (e.g.,%CATALINA_HOME%\webbapps\<APP_FOLDER>\WEB-INF\lib
). - Copy
sigsci-module-java-{version}.jar
and its dependencies in thelib
folder to your application’s classpath (e.g.,%CATALINA_HOME%\webbapps\<APP_FOLDER>\WEB-INF\lib
). If you already have any of the dependency jar files in your application classpath folder (i.e., for Tomcat in theWEB-INF\lib
) then it is not necessary to copy them, even if the version numbers are different. The logging jars are optional based on howslf4j
is configured.
- Copy
Access with Maven
For projects using Maven for build or deployment, the latest version of Next-Gen WAF Java modules can be installed by adding XML to the project pom.xml
file. For example:
123456789101112
<repositories> <repository> <id>sigsci-stable</id> <url>https://packages.signalsciences.net/release/maven2</url> </repository></repositories>
<dependency> <groupId>com.signalsciences</groupId> <artifactId>sigsci-module-java</artifactId> <version>LATEST_MODULE_VERSION</version></dependency>
Be sure to replace LATEST_MODULE_VERSION
with the latest release of the Java module. You can find the latest version in our version file at https://dl.signalsciences.net/sigsci-module-java/VERSION.
Install and configure
Create a new instance of WafHandler
for every new connection.
WafHandler
must be added afterFlowControlHandler
.HttpObjectAggregator
handler should be added beforeFlowControlHandler
to inspect HTTP Post body.WafHandler
may sendHttpResponse
for blocked request.
Example deployment
12345678910111213141516171819202122232425
// Update configurationWafHandler.getSigSciConfig().setMaxPost(40000);
// start server and handle requestsnew ServerBootstrap().group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).childHandler( new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline() .addLast(new HttpServerCodec()) .addLast(new HttpObjectAggregator(6 * (1 << 20))) .addLast(new FlowControlHandler()) .addLast("waf", new WafHandler()) .addLast(new SimpleChannelInboundHandler<FullHttpRequest>() {
// send response
}); } }).bind(8080).sync();
Do not use this form to send sensitive information. If you need assistance, contact support. This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.