PHPackages                             envoyr/nginx-configurator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. envoyr/nginx-configurator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

envoyr/nginx-configurator
=========================

1.2.1(5mo ago)3708MITPHP

Since Oct 27Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/envoyr/nginx-configurator)[ Packagist](https://packagist.org/packages/envoyr/nginx-configurator)[ Docs](https://envoyr.com/)[ RSS](/packages/envoyr-nginx-configurator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)DependenciesVersions (5)Used By (0)

NGINX Configurator
==================

[](#nginx-configurator)

PHP Library for NGINX configuration generator.

[![PHP 8.1](https://camo.githubusercontent.com/977e0696204af3989fc512d04fbc04a456d032a8b5bfc54669a56c1a62a5fcdb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312d3843394342362e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/977e0696204af3989fc512d04fbc04a456d032a8b5bfc54669a56c1a62a5fcdb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312d3843394342362e7376673f7374796c653d666c6174)

---

Installation
------------

[](#installation)

Install with Composer

```
composer require envoyr/nginx-configurator

```

Requirements
------------

[](#requirements)

This library requires *PHP* in `^8.1` version.

Usage
-----

[](#usage)

Generating configuration string:

```
use Envoyr\NginxConfigurator\Factory;
use Envoyr\NginxConfigurator\Builder;
use Envoyr\NginxConfigurator\Config\Location;
use Envoyr\NginxConfigurator\Node\Directive;
use Envoyr\NginxConfigurator\Node\Literal;
use Envoyr\NginxConfigurator\Node\Param;

require __DIR__ . '/../vendor/autoload.php';

$factory = new Factory()
$builder = new Builder();

$server = $builder->append($factory->createServer(80));
$server->append(new Directive('error_log', [
    new Param('/var/log/nginx/error.log'),
    new Param('debug'),
]));
$server->append(new Location(new Param('/test'), null, [
    new Directive('error_page', [new Param('401'), new Param('@unauthorized')]),
    new Directive('set', [new Param('$auth_user'), new Literal('none')]),
    new Directive('auth_request', [new Param('/auth')]),
    new Directive('proxy_pass', [new Param('http://test-service')]),
]));
$server->append(new Location(new Param('/auth'), null, [
    new Directive('proxy_pass', [new Param('http://auth-service:9999')]),
    new Directive('proxy_bind', [new Param('$server_addr')]),
    new Directive('proxy_redirect', [new Param('http://$host'), new Param('https://$host')]),
    new Directive('proxy_set_header', [new Param('Content-Length'), new Literal("")]),
    new Directive('proxy_pass_request_body', [new Param('off')]),
]));
$server->append(new Location(new Param('@unauthorized'), null, [
    new Directive('return', [new Param('302'), new Param('/login?backurl=$request_uri')]),
]));
$server->append(new Location(new Param('/login'), null, [
    new Directive('expires', [new Param('-1')]),
    new Directive('proxy_pass', [new Param('http://identity-provider-service')]),
    new Directive('proxy_bind', [new Param('$server_addr')]),
    new Directive('proxy_redirect', [new Param('http://$host'), new Param('https://$host')]),
    new Directive('proxy_set_header', [new Param('Content-Length'), new Literal("")]),
    new Directive('proxy_pass_request_body', [new Param('off')]),
]));

print($builder->dump());
```

Generated configuration output:

```
server {
        listen 80;
        listen [::]:80 default ipv6only=on;
        error_log /var/log/nginx/error.log debug;
        location  /test {
                error_page 401 @unauthorized;
                set $auth_user "none";
                auth_request /auth;
                proxy_pass http://test-service;
        }

        location  /auth {
                proxy_pass http://auth-service:9999;
                proxy_bind $server_addr;
                proxy_redirect http://$host https://$host;
                proxy_set_header Content-Length "";
                proxy_pass_request_body off;
        }

        location  @unauthorized {
                return 302 /login?backurl=$request_uri;
        }

        location  /login {
                expires -1;
                proxy_pass http://identity-provider-service;
                proxy_bind $server_addr;
                proxy_redirect http://$host https://$host;
                proxy_set_header Content-Length "";
                proxy_pass_request_body off;
        }

}

```

License
-------

[](#license)

The MIT License (MIT)

Copyright (c) 2016 Madkom S.A. Copyright (c) 2022 envoyr

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance70

Regular maintenance activity

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~373 days

Total

4

Last Release

169d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/64a10ad37cbd186601e725d894b9f35bdb9ec47782d9751a36e639d4ae795174?d=identicon)[envoyr](/maintainers/envoyr)

---

Top Contributors

[![envoyr](https://avatars.githubusercontent.com/u/81368729?v=4)](https://github.com/envoyr "envoyr (11 commits)")[![brzuchal](https://avatars.githubusercontent.com/u/3149753?v=4)](https://github.com/brzuchal "brzuchal (9 commits)")

### Embed Badge

![Health badge](/badges/envoyr-nginx-configurator/health.svg)

```
[![Health](https://phpackages.com/badges/envoyr-nginx-configurator/health.svg)](https://phpackages.com/packages/envoyr-nginx-configurator)
```

###  Alternatives

[anteris-dev/data-transfer-object-factory

Gives an easy-to-use API for mocking Data Transfer Objects.

4087.4k](/packages/anteris-dev-data-transfer-object-factory)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
