Skip to content

Nginx does not allow nested http directives #21

Description

@ajn142attamu

Describe the bug
Documentation indicates waf_maps.conf should be included within the nginx.conf http directive. However, waf_maps.conf contains an http directive. Nginx does not permit nested http directives, resulting in

root@instance-20231029-2110:/home/ubuntu# nginx -t && service nginx reload
2026/06/08 01:57:07 [emerg] 1166803#1166803: "http" directive is not allowed here in /etc/nginx/waf_patterns/waf_maps.conf:3
nginx: configuration file /etc/nginx/nginx.conf test failed

This can be validated with a minimal test case:

Running nginx -t -c /path/to/test against:

http { }

passes without errors, while running the same against

http { http { } }

replicates the same error message

To Reproduce
Steps to reproduce the behavior:

  1. Start with functioning nginx site.
  2. Follow documentation at https://fabriziosalmi.github.io/patterns/nginx.
  3. Run nginx -t
  4. See error

Expected behavior
Following documentation results in working site

Error messages/logs
If applicable, add error messages or log output to help explain your problem.

Provided above

Environment (please complete the following information):

  • OS: Ubuntu 24.04.1
  • Python Version: N/a
  • Web Server: Nginx 1.24.0
  • Installation Method: downloaded pre-generated configs

Additional context

I suspect a contributing factor is that the nginx rule tests use nginxinc/crossplane to parse the configs, but don’t test the evaluation with a demo nginx site.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions