Deploy Nginx Config with GitHub Actions

Treat server config like code: review it in a pull request, validate it with nginx -t in CI, and deploy it only from the main branch. A failed test then can never take a site down.

Test in CI

Run nginx -t against the changed files before merge so syntax errors are caught in the pull request.

docker run --rm -v "$PWD/conf:/etc/nginx/conf.d:ro" nginx:stable nginx -t

Deploy safely

Copy files over SSH, run nginx -t on the server, and reload only if it exits zero. Pin the host key instead of trusting on first use.

Open the CI/CD snippets generator

Frequently asked questions

Reload or restart?

Reload. It applies the new config gracefully and keeps the old workers if the new config is invalid.

Guides