envoyr/nginx-configurator
Composer 安装命令:
composer require envoyr/nginx-configurator
包简介
README 文档
README
PHP Library for NGINX configuration generator.
Installation
Install with Composer
composer require envoyr/nginx-configurator
Requirements
This library requires PHP in ^8.1 version.
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
The MIT License (MIT)
Copyright (c) 2016 Madkom S.A. Copyright (c) 2022 envoyr hello@envoyr.com
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.
envoyr/nginx-configurator 适用场景与选型建议
envoyr/nginx-configurator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 756 次下载、GitHub Stars 达 4, 最近一次更新时间为 2022 年 10 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 envoyr/nginx-configurator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 envoyr/nginx-configurator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 756
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-27