Docs / Cloud & DevOps / Canary Deployments with Nginx and Lua

Canary Deployments with Nginx and Lua

By Admin · Feb 16, 2026 · Updated Apr 24, 2026 · 5 views · 2 min read

In this article, we'll walk through the complete process of working with canary in a server environment. Understanding nginx is essential for maintaining a reliable and performant infrastructure.

Prerequisites

  • Basic familiarity with the Linux command line
  • A registered domain name (for public-facing services)
  • Basic understanding of CI/CD concepts
  • Root or sudo access to the server
  • A VPS running Ubuntu 22.04 or later (2GB+ RAM recommended)

Pipeline Configuration

Before making changes to the configuration, always create a backup of the existing files. This ensures you can quickly roll back if something goes wrong during the setup process.


# .github/workflows/deploy.yml
name: Deploy to Production
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build
        run: |
          docker build -t myapp:latest .
      - name: Deploy
        run: |
          ssh deploy@server 'cd /opt/myapp && docker compose pull && docker compose up -d'

These commands should be run as root or with sudo privileges. If you're using a non-root user, prefix each command with sudo.

Build and Test Setup

The default configuration works well for development environments, but production servers require additional tuning. Pay particular attention to connection limits, timeout values, and logging settings.


# Set up deployment pipeline
mkdir -p /opt/myapp
cd /opt/myapp

# Create deployment script
cat << 'EOF' > deploy.sh
#!/bin/bash
set -euo pipefail
echo "Deploying version: $1"
docker pull myapp:$1
docker compose down
DOCKER_TAG=$1 docker compose up -d
echo "Deployment complete"
EOF
chmod +x deploy.sh

The configuration above sets the recommended values for a VPS with 2-4GB of RAM. Adjust the memory-related settings proportionally if your server has different specifications.

Important Notes

It's recommended to test this configuration in a staging environment before deploying to production. This helps identify potential compatibility issues and allows you to benchmark performance differences.

Summary

You've successfully configured canary on your VPS. Remember to monitor performance, keep your software updated, and maintain regular backups. If you run into issues, consult the official documentation or open a support ticket for assistance.

Was this article helpful?