Asa*_*ine 8 config nginx formatter
例如,我有这个混乱的配置:
server {
listen 80 default;
server_name localhost;
location / {
proxy_method $foo;
proxy_pass http://foobar:8080;
}
}
Run Code Online (Sandbox Code Playgroud)
我想让它看起来像:
server
{
listen 80 default;
server_name localhost;
location /
{
proxy_method $foo;
proxy_pass http://foobar:8080;
}
}
Run Code Online (Sandbox Code Playgroud)
如何以更好的方式格式化 Nginx 配置?
有一些格式化程序,例如:
从 npm (nodejs 包管理器)安装它:
npm install -G nginxbeautifier
Run Code Online (Sandbox Code Playgroud)
从 arch aur (arch 用户存储库)安装它:
pacaur -S nginxbeautifier
Run Code Online (Sandbox Code Playgroud)
从 github 存储库(git和github)克隆:
git clone https://github.com/vasilevich/nginxbeautifier.git
Run Code Online (Sandbox Code Playgroud)
执行 nginxbeautifier -h 或 nginxbeautifier --help 后,即可获得有关如何在本地使用该程序的说明,也可以在 github 页面本身上找到。
完全披露我是“nginxbeautifier.com”和相关 github 页面的开发者和维护者
,请报告那里的任何问题,
nginxbeautifier 中的一些代码实际上是受到提到的第一个选项的启发。