# nG-SetEnvIf **Repository Path**: web/nG-SetEnvIf ## Basic Information - **Project Name**: nG-SetEnvIf - **Description**: No description available - **Primary Language**: Unknown - **License**: GPL-3.0 - **Default Branch**: develop - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-01-02 - **Last Updated**: 2026-01-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
# nG-SetEnvIf [![](https://custom-icon-badges.demolab.com/badge/freenginx-1.29.2-009639?logo=freenginx&logoColor=white)](https://freenginx.org/en/) ![](https://img.shields.io/badge/Apache-2.4.65-D22128?logo=Apache&logoColor=white) [![ReDoS detector](https://github.com/t18d/nG-SetEnvIf/actions/workflows/redos-detector.yml/badge.svg?branch=staging)](https://github.com/t18d/nG-SetEnvIf/actions/workflows/redos-detector.yml)   [![](https://custom-icon-badges.demolab.com/badge/Perishable%20Press-8G%20v1.5-dd6d0b.svg?logo=perishable-press)](https://perishablepress.com/8g-firewall/)

a project of Open Source by Tonkünstler-on-the-Bund

      nG-SetEnvIf is an [nG Firewall](https://perishablepress.com/ng-firewall/) fork that focusses on performance. It can be used with both nginx and Apache httpd. [Installation](#installation) • [Configuration](#configuration) • [Recipes](#recipes)
## Installation ### nginx In `http` context, add ```Nginx include /path/to/8g-firewall.conf; ``` In the relevant `server` context, add ```Nginx include /path/to/8g.conf; ``` ### Apache In the relevant `` section, add ```ApacheConf Include /path/to/8G-SetEnvIf ``` ## Configuration ### nginx To enable logging, add `$ng_reason` to the relevant `log_format` directive. For best performance, add to the main context ```Nginx pcre_jit on; ``` and place the `include` directive before any `if`, `rewrite` or `set` within the same context. ### Apache The eponymous module, mod_setenvif, is required, as is mod_authz_core. This is [more efficient](https://httpd.apache.org/docs/trunk/rewrite/avoid.html) than using mod_rewrite. For best performance, `httpd.conf` [should be used](https://httpd.apache.org/docs/trunk/howto/htaccess.html#when) in preference to `.htaccess`. > [!WARNING] > Test with [Starr's logging suite](https://perishablepress.com/ng-firewall-logging/) and mod_rewrite before deploying in production. ## Recipes If even nG-SetEnvIf fails to satisfy your passion for performance, read on. - [Maxim Dounin’s Q&A](https://github.com/t18d/nG-SetEnvIf/wiki/Maxim-Dounin’s-Q&A) (nginx) - [Post-quantum KEM](https://github.com/t18d/nG-SetEnvIf/wiki/Recipes#post-quantum-kem) - [URL normalisation](https://github.com/t18d/nG-SetEnvIf/wiki/Recipes#url-normalisation) - [Block AI crawlers](https://github.com/t18d/nG-SetEnvIf/wiki/Recipes#ai-crawlers) - [Block spam emails](https://github.com/t18d/nG-SetEnvIf/wiki/Recipes#spam-emails) - [Replace mod_rewrite](https://github.com/t18d/nG-SetEnvIf/wiki/Recipes#disable-mod_rewrite-altogether) (Apache) - [Rate-limiting](https://github.com/t18d/nG-SetEnvIf/wiki/Recipes#rate-limit-404s) (WP) - [Integration with Cloudflare](https://github.com/t18d/nG-SetEnvIf/wiki/Recipes#cloudflare)  
**Our Sponsor:**