SuperAPI AI 工具集

nginx

部署与运维

查看项目

更新于 10-15 23:48

技能介绍

用途:该技能用于 nginx Web 服务器与反向代理的日常管理,帮助处理配置语法、虚拟主机、反向代理、SSL/TLS、负载均衡、上游配置和限流等任务。

主要能力:提供身份信息(服务单元 nginx.service,配置位于 /etc/nginx/nginx.conf、/etc/nginx/sites-enabled/、/etc/nginx/conf.d/,日志见 journalctl -u nginx 及 /var/log/nginx/ 下的 access.log、error.log,运行用户为 Debian/Ubuntu 的 www-data 或 RHEL/Fedora 的 nginx);关键操作包括校验配置 nginx -t、导出合并配置 nginx -T、无停机重载 sudo systemctl reload nginx、重启 sudo systemctl restart nginx、测试指定配置 nginx -t -c /path/to/test.conf;端口为 80/tcp 与 443/tcp,可用 ss -tlnp | grep nginx 验证,防火墙可用 sudo ufw allow 'Nginx Full' 或 sudo ufw allow 80,443/tcp;健康检查包括 systemctl is-active nginx、nginx -t 2>&1、curl -sI http://localhost、ss -tlnp | grep ':80|:443'。

常见故障排查:端口占用导致 bind() 失败、502 上游不可用、504 上游过慢、包含文件语法错误导致重载失败、socket 权限、SSL 协议错误、打开文件数过多、413 请求体过大等,均给出检查与修复方向。

注意事项:proxy_pass 末尾斜杠会剥离 location 前缀;sites-enabled 中的失效符号链接会被静默忽略;最大客户端数由 worker_connections 与 worker_processes 共同决定;default_server 缺失时首个虚拟主机接收未匹配请求;正则 server_name 优先于字面匹配;上游 keepalive 需同时设置 keepalive、proxy_http_version 1.1 与 proxy_set_header Connection "";try_files 末参数是回退 URI 或响应码而非文件路径。

限制:资料未提供具体安装以外的平台支持范围、收费方式或效果保证;references/ 目录包含 nginx.conf.annotated、common-patterns.md 与 docs.md 等参考文件。