[PATCH] Support for Custom HTTP Status Code in deny Directive

Fabiano Furtado Pessoa Coelho fusca14 at gmail.com
Fri Aug 29 00:39:31 UTC 2025


Dear NGINX Open Source Community,

I hope this message finds you well.

Recently, I encountered a use case where I needed the deny directive
from the ngx_http_access_module to return a different HTTP status code
than the default 403 (Forbidden). To address this, I developed a small
patch that allows specifying a custom status code directly in the
directive.

This patch adds support for a second parameter to the deny directive,
enabling the user to define the HTTP return code. At the moment, the
patch supports only 403 (NGX_HTTP_FORBIDDEN) and 404
(NGX_HTTP_NOT_FOUND), but it can easily be modified to accept other
status codes as needed.

I believe this enhancement might be useful for others in similar
situations. The patch is attached for your reference, review and
consideration. I would be grateful if you could consider including it
in the official open source project.

Thank you for your time.
Fabiano Furtado
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ngx_http_access_module.c.patch
Type: text/x-patch
Size: 5212 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20250828/9e529285/attachment-0001.bin>


More information about the nginx mailing list