linux - Nginx 配置版本控制策略

标签 linux git nginx version-control config

目前,我的团队继承的一个项目在 10 多个环境中的 nginx 配置完全困惑,我们想实现版本控制策略,但我不确定人们“通常”如何实现这一目标。您将整个 nginx conf 文件夹设为一个 git repo 并忽略您不想要的版本?或者有一个包含配置文件 repo 的单独文件夹并使用脚本部署文件?

最佳答案

我们通过单独的 Git 存储库管理它,专用于 nginx 配置。是的,它包括 /etc/nginx/ 目录中的所有内容。

但它没有直接在服务器上同步,而是使用 bash 脚本来 pull 更改、更新配置和重新加载 nginx 配置。

脚本示例:

# Pull changes
git pull

# Sync changes excluding .git directory
rsync -qauh ./* "/etc/nginx" --exclude=".git"

# Set proper permissions
chmod -R 644 /etc/nginx
find /etc/nginx -type d -exec chmod 700 {} \;

# If you store SSL certs under `/etc/nginx/ssl`
# Set proper permission for SSL certs 
chmod -R 600 /etc/nginx/ssl
chmod -R 400 /etc/nginx/ssl/*

# Reload nginx config
# but only if configtest is passed
nginx -t && service nginx reload

关于linux - Nginx 配置版本控制策略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44159978/

相关文章:

c - 使用套接字通信在 stdout 上打印的剩余字符

css - Nginx 无法加载 CSS 和 JS 文件(MIME 类型错误)?

linux - Nginx 因 “Out of memory” 被杀死?

linux - 在 qemu 中引导 ppc linux 内核

linux - 仅查找从当前目录开始且设置了 setuid 位的文件

git - 我如何检查谁对 Github 上的公共(public)组织存储库具有写入权限?

用于 Web 部署的 Git 与 FTP

git - 如何从 git 历史记录中删除提交,就好像它根本不存在一样?

node.js - 如何将 NodeJS 与 Angular 连接(在 Nginx 中)

linux - 我可以在主目录中安装 Mercurial 吗?