Connect Akto with NGINX
If your API calls are being routed through NGINX, you can use Akto's NGINX module to send traffic to Akto dashboard. Below guide will help you do this:
Creating AWS Policy
1. Go to Quick Start on your Akto dashboard and expand the Connect traffic data
section.
2. Scroll down to Data processors setup
section.
3. Copy the policy json
and click on the Akto Dashboard role link.
4. Click
on the JSON
tab and paste the policy
5. Click on Review policy
button.
6. Enter AktoDashboardPolicy
as the policy name and click
on Create Policy
button
8. Once the policy is created, go back to the dashboard
.
Setting up Data processors
1. Click on Setup traffic processors
button.
2. This will bring up infra that will process your traffic.
3. Check that you have AKTO_NLB
and AKTO_MONGO_IP
vars once setup is complete.
Add NGINX module
This methods is recommended when you have end to end TLS and SSL termination happens at NGINX.
Record all API calls using
nginx-module-njs
. (njs is a standard NGINX module built and shipped in every release of NGINX). You can install it by runningapt install nginx-module-njs
The data is sent to Akto installed in your VPC using nginx-kafka-log-module. You can install it by using nginx dynamic modules functionality as described here
Download the js file and save as
/etc/nginx/njs/api_log.js
In your NGINX conf file -
/etc/nginx/nginx.conf
, add the following:
add the following lines in http
section of /etc/nginx/nginx.conf
:
5. In /etc/nginx/conf.d/default.conf
, add 2 lines in server > location
section
6. Restart NGINX by nginx -s reload
. This will start logging all the request-response logs to akto.
Note: We have benchmarked an nginx server with and without akto nginx traffic module. The results for the same are as follows:
The server setup being used is an AWS EC2 (t3a.small: 2CPU + 2GB RAM), with around 1600-1800 requests being fired per second to the server continuously for over a minute (~110k requests per minute). Here nginx is configured as a reverse proxy to a node.js backend server.
Last updated