「Nginx」- 配置文件语法(学习笔记) @20210304

使用变量

Alphabetical index of variables
reverse proxy - nginx - read custom header from upstream server - Stack Overflow

通过 $http_<header-field> 形式,可以引用请求头的字段。比如:
1)$http_user_agent:获取请求头的 User-Agent 字段;
2)$http_x_real_ip:引用请求头的 X-Real-IP 字段;

配置文件格式化

Is there a formatter/beautifier for NGINX config files?

命令行工具:
1)Nginx Formatter,这是目前(05/22/2019)能找到的、Star 比较多的项目(使用 Python 开发)
2)nginxbeautifier,需要使用 NodeJS 环境来安装运行(我们不会为了格式化 Nginx 配置而在主机中安装 NodeJS 环境)。
3)conffmt,该项目比较久

在线工具(对于 Nginx 配置格式化,实质是对配置行的正确缩进):
1)Online JavaScript beautifier

配置文件生成工具

digitalocean/nginxconfig.io: ⚙️ NGINX config generator on steroids 💉
演示站点:NGINX Config | DigitalOcean


posted @ 2021-03-04 18:35  研究林纳斯写的  阅读(68)  评论(0编辑  收藏  举报