The FireTail NGINX module is a dynamic module that integrates with the FireTail platform to enhance your API's logging and validation capabilities.
Use the Dockerfile to build the FireTail NGINX module, install it in an NGINX Docker image, and set up a custom nginx.conf
and index.html
.
To get started with the Docker setup:
1. Clone the repository:
2. Build the Docker image:
3. Run the Docker container:
When you make a request to localhost:8080
, you may see a log entry like:
This indicates that the FireTail NGINX Module is receiving 401 responses due to an unconfigured API token. To resolve this, update the nginx.conf
with a valid FireTail logs API token:
To demonstrate request validation, a POST /proxy/profile/{username}/comment
operation is defined in the provided appspec.yml
, with one profile defined in the provided nginx.conf
: POST /proxy/profile/alice/comment
. A proxy_pass
directive is used to forward requests to /profile/alice/comment
as the request body validation will not occur on locations where the return
directive is used.
Making a curl request to POST /profile/alice/comment
should yield the following result, which validates successfully against the provided appspec
:
If you alter the request body in any way that deviates from the appspec
, you will receive an error response from the FireTail nginx module:
To demonstrate response validation, a GET /profile/{username}
operation is defined in the provided appspec.yml
, and two profiles are defined in the provided nginx.conf
: GET /profile/alice
and GET /profile/bob
.
Making a curl request to GET /profile/alice
should yield the following result, which validates successfully against the provided appspec
, as it returns only Alice's username and friend count:
Making a curl request to GET /profile/bob
will yield a different result, as the response body defined in our nginx.conf
erroneously includes Bob's address. This does not validate against our appspec
, so the response body is overwritten by the FireTail middleware, which can protect Bob from having his personally identifiable information disclosed by our faulty application. For the purposes of this demo, the FireTail library's debugging responses are enabled, providing an explanation of the problem:
For local development with VSCode:
1. Download and configure the NGINX tarball:
2. Install VSCode's Microsoft C/C++ Extension. Ensure it can find your NGINX headers. If not, adjust the includePath in settings:
C/C++: Edit configurations (UI)
${workspaceFolder}/**
3. Install dependencies using vcpkg:
To compile the FireTail NGINX module, follow the NGINX documentation on compiling dynamic modules.
1. Clone the repository:
2. Download and extract the matching NGINX release:
3. Generate a makefile to build the dynamic module:
4. Install the FireTail NGINX Module's dependencies, curl and json-c, before running:
The FireTail NGINX module provides several directives to configure its behavior. To configure the FireTail NGINX Module:
To avoid placing plaintext credentials in your nginx.conf
, use a module like ngx_http_lua_module
and instead make use of system environment variables.
Note: Refer to dev/nginx.conf
for an example configuration.
Here are the some directives that can be used:
firetail_url
directive.