A step-by-step guide covering real-world troubleshooting during the upgrade process, HTTP/2 syntax changes, and differences between package managers.
In May 2026, a critical NGINX vulnerability was disclosed, affecting millions of servers. This guide documents the real upgrade process across two distinct environments—Debian 13 and Alpine Linux—including the issues encountered and how to resolve them.
The Vulnerability: CVE-2026-42945 (NGINX Rift)
The catalyst for this update was NGINX Rift, a critical heap buffer overflow that had remained undetected in NGINX’s codebase for 18 years. The flaw resides in ngx_http_rewrite_module, included in every standard NGINX installation. It is triggered when a rewrite directive combines unnamed PCRE captures (the $1, $2 syntax) with a replacement string containing a question mark, followed by another rewrite, if, or set. NGINX calculates the buffer size using one escaping method but writes the result using another, allowing the bytes written out of bounds to be controlled by an attacker.
F5 rates this vulnerability with a CVSS v4 score of 9.2 (Critical). If you operate an internet-facing NGINX instance with non-trivial rewrite rules, PHP setups, WordPress permalinks, or API gateways, this is critical right now. The fix is available starting with version 1.30.1.
Upgrading NGINX on Debian 13
| Status | Version |
|---|---|
| Vulnerable | 1.26.3 |
| Patched | 1.30.1 |
1. Verify the Installed Version
Before starting, check which version of NGINX is currently running and which repository it originated from.
nginx -v
apt policy nginx
2. Install Dependencies and Add the Official Repository
Although Debian includes NGINX in its official repositories, their packaged versions tend to be more conservative. To quickly obtain a patched version, use the official NGINX repository.
Install required dependencies
sudo apt update
sudo apt install curl gnupg2 ca-certificates lsb-release debian-archive-keyring -y
Import the official GPG key
curl -fsSL https://nginx.org/keys/nginx_signing.key | \
sudo gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg
Add the stable repository
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
https://nginx.org/packages/debian `lsb_release -cs` nginx" | \
sudo tee /etc/apt/sources.list.d/nginx.list
Update package indexes
sudo apt update
3. Install the Patched Version
sudo apt install nginx
Recommendation: If you already have virtual hosts, SSL certificates, or custom configurations in place, choose to keep your locally installed version when Debian prompts you about existing configuration files. Otherwise, you risk overwriting production settings.
4. Start and Enable the Service
Issue encountered: After installing from the official repository, the service was not started automatically. You need to start it manually.
sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl status nginx
5. Validate Configuration and Version
sudo nginx -t
nginx -v
Expected output from nginx -t:
syntax is ok
test is successful
HTTP/2 Warning in Recent Versions
Starting with NGINX 1.25.1, HTTP/2 support was decoupled from the listen directive to allow greater configuration flexibility. The legacy syntax still works, but it emits warnings.
To find configurations still using the legacy syntax:
sudo grep -E "listen.*http2" -R /etc/nginx/
| Syntax | |
|---|---|
| Legacy | listen 443 ssl http2; |
| New (recommended) | listen 443 ssl; + http2 on; (inside the server block) |
# Nueva sintaxis
listen 443 ssl;
http2 on;
Quick Summary – Debian 13
sudo apt update
sudo apt install curl gnupg2 ca-certificates lsb-release debian-archive-keyring -y
curl -fsSL https://nginx.org/keys/nginx_signing.key | \
sudo gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
https://nginx.org/packages/debian `lsb_release -cs` nginx" | \
sudo tee /etc/apt/sources.list.d/nginx.list
sudo apt update && sudo apt install nginx
sudo systemctl start nginx
sudo systemctl enable nginx
sudo nginx -t && nginx -v
Upgrading NGINX on Alpine Linux
| Status | Version |
|---|---|
| Vulnerable (stable branch) | 1.28.3-r1 |
| Patched (edge branch) | 1.30.1-r0 |
On Alpine, the stable branch still shipped a vulnerable version, making it necessary to pull temporarily from the edge branch. The key is doing this in a controlled manner using a pinned tag (@edge) to strictly limit which packages are installed from there, without destabilizing the rest of the system.
1. Add the Edge Repository with a Pinned Tag
vi /etc/apk/repositories
Add the following line to the end of the file:
@edge https://dl-cdn.alpinelinux.org/alpine/edge/main
Save and exit: ESC -> :wq -> ENTER
Why use the
@edgetag? Without it, Alpine might upgrade other system packages from theedgebranch, which can introduce instability. The tag restricts repository usage strictly to packages that explicitly reference it.
2. Update Indexes and Install from Edge
sudo apk update
sudo apk add nginx@edge
Issue encountered: If the repository was not properly configured with
@edge, Alpine outputs:
WARNING: The repository tag for world dependency 'nginx@edge' does not exist
Verify with
cat /etc/apk/repositoriesthat the line starts with the exact@edgeprefix and that the command targetsnginx@edge. Both must match.
3. Restart and Validate
sudo rc-service nginx restart
sudo nginx -v
sudo nginx -t
Automatically Generated .apk-new File
During installation, Alpine may generate /etc/nginx/nginx.conf.apk-new. This is expected behavior: the package manager creates this backup whenever it detects a locally modified configuration. If nginx -t validates successfully, this file can safely be ignored or compared manually later.
Final Recommendations
After applying critical NGINX updates:
- Always verify the active running version with
nginx -v - Run
nginx -tbefore restarting production services - Review syntax changes across major versions (especially HTTP/2)
- Ensure the service is properly started and enabled
- On Alpine, avoid enabling
edgerepositories globally without restricted tags
Patching Is Only the First Step
Updating NGINX may sound straightforward, but in production scenarios, operational details emerge that aren’t always documented in the official guides: repositories missing upstream patches, services failing to restart automatically, silent syntax deprecations, and differences across package managers.
Documenting these findings makes it easy to replicate the procedure across multiple servers or automate it through Ansible, Terraform, or CI/CD pipelines.