如何对 Nginx 配置文件应用一致的缩进和格式?
How can I apply consistent indentation and formatting to Nginx config files?
我有这个乱七八糟的配置,例如:
server {
listen 80 default;
server_name localhost;
location / {
proxy_method $foo;
proxy_pass http://foobar:8080;
}
}
我想让它看起来像:
server
{
listen 80 default;
server_name localhost;
location /
{
proxy_method $foo;
proxy_pass http://foobar:8080;
}
}
如何更好地格式化 Nginx 配置?
任何在线/文本编辑器的代码美化器都应该做这项工作,尝试不同的语言以获得完美的缩进。
上述网站的示例输出:
server {
listen 80
default;
server_name localhost;
location / {
proxy_method $foo;
proxy_pass http: //foobar:8080;
}
}
有一些格式化程序,例如:
- Nginx Formatter (python) 由 1connect 提供,它有一个不错的本地 运行 可用工具,非常好用!
- Nginx Formatter (python)at blindage.org ,没有尝试那个,但从他的示例输出来看似乎不错。
- Nginx Beautifier(javascript) also available at nginxbeautifier.com as a tiny js tool just like jsbeautifier.com and of course also open source on github 你也可以 运行 在本地通过:
installing it from npm(nodejs package manager):
npm install -G nginxbeautifier
installing it from arch aur (arch user repository):
pacaur -S nginxbeautifier
cloning from by github repository(git and github):
git clone https://github.com/vasilevich/nginxbeautifier.git
有关如何在本地使用该程序的说明,一旦您
执行
nginxbeautifier -h
要么
nginxbeautifier --help
以及 github 页面本身。
完全公开我是 "nginxbeautifier.com"
的开发者和维护者
以及相关的 github 页面
请报告那里的任何问题,
nginxbeautifier 中的一些代码是
受到第一个选项的启发。
我有这个乱七八糟的配置,例如:
server {
listen 80 default;
server_name localhost;
location / {
proxy_method $foo;
proxy_pass http://foobar:8080;
}
}
我想让它看起来像:
server
{
listen 80 default;
server_name localhost;
location /
{
proxy_method $foo;
proxy_pass http://foobar:8080;
}
}
如何更好地格式化 Nginx 配置?
任何在线/文本编辑器的代码美化器都应该做这项工作,尝试不同的语言以获得完美的缩进。
上述网站的示例输出:
server {
listen 80
default;
server_name localhost;
location / {
proxy_method $foo;
proxy_pass http: //foobar:8080;
}
}
有一些格式化程序,例如:
- Nginx Formatter (python) 由 1connect 提供,它有一个不错的本地 运行 可用工具,非常好用!
- Nginx Formatter (python)at blindage.org ,没有尝试那个,但从他的示例输出来看似乎不错。
- Nginx Beautifier(javascript) also available at nginxbeautifier.com as a tiny js tool just like jsbeautifier.com and of course also open source on github 你也可以 运行 在本地通过:
installing it from npm(nodejs package manager):
npm install -G nginxbeautifier
installing it from arch aur (arch user repository):
pacaur -S nginxbeautifier
cloning from by github repository(git and github):
git clone https://github.com/vasilevich/nginxbeautifier.git
有关如何在本地使用该程序的说明,一旦您 执行 nginxbeautifier -h 要么 nginxbeautifier --help 以及 github 页面本身。
完全公开我是 "nginxbeautifier.com"
的开发者和维护者
以及相关的 github 页面
请报告那里的任何问题,
nginxbeautifier 中的一些代码是
受到第一个选项的启发。