Configurar el repositorio

nginx2root es el nombre de tres vulnerabilidades de nginx corregidas upstream en nginx 1.30.7 y 1.31.9 el 2026-11-18: CVE-2026-123007 (HTTP/2), CVE-2026-123634 (resolver) y CVE-2026-113425 (proxy de correo).

Amazon Linux no aparece en la lista: Amazon ya incluye el nginx 1.30.7 corregido. En Amazon Linux 2 instálalo con: amazon-linux-extras install nginx1

Disponible en el repositorio.

«Fixed» mantiene la versión de nginx de tu distribución y solo le añade las correcciones de nginx2root, por lo que es una actualización directa. «Stable» es nginx 1.30.7. En Ubuntu 22.04 y 24.04, Debian 12 y 13 y Enterprise Linux 8, 9 y 10 es el paquete propio de nginx.org: NO es un sustituto directo, porque la estructura de sus paquetes difiere de la de tu distribución (un único paquete nginx, configuración en /etc/nginx/conf.d), y el script solo cambia a él si lo ejecutas con --switch. En las demás versiones es la compilación de nginx 1.30.7 de Clouding.io con los nombres y la estructura de paquetes propios de tu distribución, y el script actualiza en el sitio los paquetes instalados.

Ubuntu 22.04 LTS (Jammy): la versión de nginx de la distribución, con solo las correcciones de nginx2root (CVE-2026-123007, CVE-2026-123634, CVE-2026-113425) adaptadas por Clouding.io. Los ficheros de configuración, los módulos y la estructura se quedan como están.

Fichero de origen de APT

# nginx-repos.clouding.io: nginx (fixed) - Ubuntu 22.04 LTS (Jammy)
deb [arch=amd64 signed-by=/usr/share/keyrings/nginx-repos.clouding.io.gpg] https://nginx-repos.clouding.io/ubuntu jammy fixed

Script de actualización (copiar y pegar como root)

#!/bin/sh
# nginx-repos.clouding.io - Actualizar los paquetes nginx instalados a las compilaciones corregidas de nginx2root en Ubuntu 22.04 LTS (Jammy)
set -e
export LC_ALL=C DEBIAN_FRONTEND=noninteractive
[ "$(id -u)" = 0 ] || { echo 'Ejecuta este script como root.'; exit 1; }
CODENAME=$( (. /etc/os-release 2>/dev/null; echo "${VERSION_CODENAME:-}") )
[ -n "$CODENAME" ] || CODENAME=$(lsb_release -sc 2>/dev/null || true)
[ -n "$CODENAME" ] || CODENAME=$(sed -n "s/^DISTRIB_CODENAME=//p" /etc/lsb-release 2>/dev/null || true)
[ -n "$CODENAME" ] || CODENAME=$(sed -n "s/^VERSION=\"[0-9.]* (\([a-z]*\))\"$/\1/p" /etc/os-release 2>/dev/null || true)
[ "$CODENAME" = 'jammy' ] || { echo 'Este sistema no es Ubuntu 22.04 LTS (Jammy): se cancela.'; exit 1; }

# 0. prerequisites (only what is missing, from your distribution's own repositories)
NEED=
command -v curl >/dev/null 2>&1 || command -v wget >/dev/null 2>&1 || NEED="$NEED curl"
dpkg-query -W -f='${Status}\n' ca-certificates 2>/dev/null | grep -q ' installed$' || NEED="$NEED ca-certificates"
[ -x /usr/lib/apt/methods/https ] || NEED="$NEED apt-transport-https"
if [ -n "$NEED" ]; then
  echo 'Instalando los requisitos que faltan desde los repositorios propios de tu distribución:' $NEED
  { apt-get update && apt-get install -y --no-install-recommends $NEED; } || { echo 'No se han podido instalar los requisitos: los repositorios propios de tu distribución no son accesibles. No se ha cambiado nada.'; exit 1; }
  echo 'Requisitos instalados:' $NEED
fi

WAS_RUNNING=0; RECPIDS=; EXTRABINS=; OURB=
NGXBIN=/usr/sbin/nginx; [ -x "$NGXBIN" ] || NGXBIN=$(command -v nginx 2>/dev/null || true)
set_ourbins() {   # the binary paths that belong to the package being upgraded (or switched away from): /usr/sbin/nginx, the packages' own nginx binary, and their canonical paths
  OURB=
  for B in /usr/sbin/nginx $EXTRABINS; do
    OURB="$OURB $B"; R=$(readlink -f "$B" 2>/dev/null) || R=
    [ -z "$R" ] || OURB="$OURB $R"
  done
}
nginx_scan() {   # "PID kind" for every nginx-looking process, read from /proc (title in cmdline, binary in exe): kind = master | other (worker, cache, any nginx binary)
  for D in /proc/[0-9]*; do
    P=${D#/proc/}
    C=$({ tr '\0' ' ' < "$D/cmdline"; } 2>/dev/null) || C=
    E=$(readlink "$D/exe" 2>/dev/null) || E=
    E=${E% \(deleted\)}
    case "$C" in
      ("nginx: master process"*) echo "$P master"; continue;;
      ("nginx: "*) echo "$P other"; continue;;
    esac
    case "${E##*/}" in (nginx|nginx.*) echo "$P other";; esac
  done
}
nginx_list() {   # one "PID kind" per nginx-looking process: the /proc scan is the primary method; ps and pgrep are cross-checks that add what it missed
  { nginx_scan
    if command -v ps >/dev/null 2>&1; then ps -eo pid,args 2>/dev/null | sed -n -e 's/^ *\([0-9][0-9]*\) *nginx: master.*/\1 master/p' -e 's/^ *\([0-9][0-9]*\) *nginx: [^m].*/\1 other/p'; fi
    if command -v pgrep >/dev/null 2>&1; then pgrep -f '^nginx: master' 2>/dev/null | sed 's/$/ master/'; pgrep -f '^nginx: ' 2>/dev/null | sed 's/$/ other/'; fi
  } | sort -n | awk '!seen[$1]++'
}
nginx_ppid() { sed -n "s/^PPid:[[:space:]]*//p" "/proc/$1/status" 2>/dev/null || true; }   # parent PID (readable even when /proc/PID/exe is not)
nginx_class_one() {   # $1 = PID, $2 = kind: prints "PID kind class binary" (class: ours | foreign | unk). Every case lives in a top-level function, never inside a $( ) (old bash 4.1/4.2 mis-parses case patterns there)
  NP=$1; NK=$2
  NE=$(readlink "/proc/$NP/exe" 2>/dev/null) || NE=; NE=${NE% \(deleted\)}
  NC=$({ tr '\0' ' ' < "/proc/$NP/cmdline"; } 2>/dev/null) || NC=
  set -f; set -- $NC; set +f; NA=${4:-}
  NS=unk; NB=-
  if [ -n "$NE" ]; then
    NB=$NE
    case " $OURB " in (*" $NE "*) NS=ours;; (*) NS=foreign;; esac
  else
    case "$NA" in
      (/*) NB=$NA; case " $OURB " in (*" $NA "*) NS=ours;; (*) NS=foreign;; esac;;
    esac
  fi
  echo "$NP $NK $NS $NB"
}
nginx_class_two() {   # $1 = PID, $2 = kind, $3 = class of pass 1, $4 = binary: settles the "unk" ones (parent is one of our masters, or recorded as ours; else amb / foreign)
  NP=$1; NK=$2; NS=$3; NB=$4
  if [ "$NS" = unk ]; then
    NPP=$(nginx_ppid "$NP"); NS=
    case "$OMS" in (*" $NP "*) NS=ours;; esac
    if [ -z "$NS" ] && [ -n "$NPP" ]; then case "$OMS" in (*" $NPP "*) NS=ours;; esac; fi
    if [ -z "$NS" ]; then if [ "$NK" = master ]; then NS=amb; else NS=foreign; fi; fi
  fi
  echo "$NP $NK $NS $NB"
}
nginx_class() {   # "PID kind class binary" per nginx-looking process. class: ours = the package's binary (exe, also "(deleted)"), or an unreadable exe whose title names that
  # binary, or an unreadable exe whose parent is one of our masters / that was recorded as ours before the package change; foreign = any other binary (openresty,
  # tengine, a build under /opt or /usr/local ...) or an unreadable worker nobody vouches for; amb = an unreadable master whose title names no path: it is ours only
  # when no foreign nginx binary is known to the census
  P1=$(nginx_list | while read -r P K; do [ -n "$P" ] || continue; nginx_class_one "$P" "$K"; done)
  OMS=" $(echo "$P1" | awk '$2 == "master" && $3 == "ours" {print $1}' | tr '\n' ' ') $RECPIDS "
  P2=$(echo "$P1" | while read -r P K S B; do [ -n "$P" ] || continue; nginx_class_two "$P" "$K" "$S" "$B"; done)
  if [ -z "$(echo "$P2" | awk '$3 == "foreign" && $4 != "-" {print $1}')" ]; then echo "$P2" | awk '{ if ($3 == "amb") $3 = "ours"; print }'; else echo "$P2"; fi
}
nginx_snap() { CLS=$(nginx_class); }   # one classification of the process table; c_* read it
c_all() { echo "$CLS" | awk '$3 == "ours" {print $1}'; }
c_masters() { echo "$CLS" | awk '$2 == "master" && $3 == "ours" {print $1}'; }
c_foreign() { echo "$CLS" | awk '$3 == "foreign" {print $1}'; }
c_amb() { echo "$CLS" | awk '$3 == "amb" {print $1}'; }
nginx_running() { nginx_snap; [ -n "$(c_all)" ]; }
census() {   # $1 = heading: every nginx process OF THIS PACKAGE (master, worker, anything running its binary), then the foreign ones (listed, never touched)
  nginx_snap; echo "$1"; CN=0; NONE='(ninguno)'; UNR='ilegible'
  for P in $(c_all); do
    CN=1; echo "  PID $P  PPid $(nginx_ppid $P)  $(readlink /proc/$P/exe 2>/dev/null || echo '?')  $({ tr '\0' ' ' < /proc/$P/cmdline; } 2>/dev/null)"
  done
  [ "$CN" = 1 ] || echo "  $NONE"
  FP=$(c_foreign)
  if [ -n "$FP" ]; then
    echo 'Nota: se han encontrado procesos nginx que NO son de este paquete (otro producto o compilación, p. ej. openresty, tengine o una compilación en /opt o /usr/local). No se tocan ni se cuentan (PID, PID padre, binario o ilegible, título):'
    for P in $FP; do echo "  PID $P  PPid $(nginx_ppid $P)  $(readlink /proc/$P/exe 2>/dev/null || echo "$UNR")  $({ tr '\0' ' ' < /proc/$P/cmdline; } 2>/dev/null)"; done
  fi
}
sig() {   # $1 = signal, $2 = PIDs
  SIGW='enviando'
  echo "  $SIGW $1: $(echo $2)"; kill -"$1" $2 2>/dev/null || true
}
wait_none() {   # $1 = seconds: wait until none of OUR nginx processes is left (nothing of ours listens on the old sockets any more)
  I=0; while nginx_running && [ "$I" -lt "$1" ]; do sleep 1; I=$((I+1)); done
  ! nginx_running
}
stop_old() {   # stop EVERY old nginx process of this package: the service manager's stop, QUIT to the masters, QUIT to orphan workers, TERM after 10 s, KILL as last resort
  if [ -d /run/systemd/system ] && command -v systemctl >/dev/null 2>&1; then echo "  systemctl stop nginx"; systemctl stop nginx || true
  elif command -v service >/dev/null 2>&1 && [ -x /etc/init.d/nginx ]; then echo "  service nginx stop"; service nginx stop || true
  elif [ -x /etc/init.d/nginx ]; then echo "  /etc/init.d/nginx stop"; /etc/init.d/nginx stop || true
  fi
  nginx_snap; MP=$(c_masters)
  [ -z "$MP" ] || sig QUIT "$MP"
  nginx_snap; MPS=" $(echo $MP) "; WP=
  for X in $(c_all); do case "$MPS" in (*" $X "*) ;; (*) WP="$WP $X";; esac; done
  [ -z "$WP" ] || sig QUIT "$WP"
  wait_none 10 && return 0
  sig TERM "$(c_all)"
  wait_none 5 && return 0
  sig KILL "$(c_all)"
  wait_none 5
}
start_new() {   # the service manager's start (systemd, service, init script); the package's nginx binary itself when there is none or it fails
  if [ -d /run/systemd/system ] && command -v systemctl >/dev/null 2>&1; then echo "  systemctl start nginx"; systemctl start nginx && return 0
  elif command -v service >/dev/null 2>&1 && [ -x /etc/init.d/nginx ]; then echo "  service nginx start"; service nginx start && return 0
  elif [ -x /etc/init.d/nginx ]; then echo "  /etc/init.d/nginx start"; /etc/init.d/nginx start && return 0
  fi
  echo "  $NGXBIN"; "$NGXBIN"
}
verify_new() {   # 0 = a master of ours runs with the installed binary (its exe is readable, not deleted) and EVERY other process of ours is a child of such a master
  WHY=; WHYX='binario instalado:'; WHYU='binario desconocido (/proc/PID/exe no es legible), no se puede verificar'; WHYP='su padre no es un master actual de nginx (proceso antiguo, PID padre:'
  nginx_snap
  NGX=$(readlink -f "$NGXBIN" 2>/dev/null || echo "$NGXBIN")
  MS=$(c_masters); MSP=" $(echo $MS) "
  if [ -z "$MS" ]; then WHY='no hay ningún proceso master de nginx en ejecución'; return 1; fi
  for P in $(c_all); do
    E=$(readlink /proc/$P/exe 2>/dev/null) || E=
    case "$MSP" in
      (*" $P "*)   # a master: its binary must be readable and be the installed one
        [ -n "$E" ] || { WHY="PID $P: $WHYU"; return 1; }
        [ "$E" = "$NGX" ] || { WHY="PID $P: $E ($WHYX $NGX)"; return 1; };;
      (*)   # a worker or other process: its parent must be a current master (an orphan with PPid 1 is an old process); an unreadable exe is unknown, never success
        PP=$(nginx_ppid $P)
        case "$MSP" in (*" $PP "*) ;; (*) WHY="PID $P: $WHYP $PP)"; return 1;; esac
        [ -z "$E" ] || [ "$E" = "$NGX" ] || { WHY="PID $P: $E ($WHYX $NGX)"; return 1; };;
    esac
  done
  return 0
}
foreign_hint() {   # a foreign nginx-derived process may be what keeps ours from starting (port 80/443)
  nginx_snap; FP=$(c_foreign)
  [ -z "$FP" ] || echo 'Se está ejecutando otro programa derivado de nginx. Si ocupa el puerto 80/443, el nuevo nginx no puede arrancar: deténlo o cambia sus puertos y arranca nginx. PID(s):' "$(echo $FP)"
}
serve_new() {   # nginx was running before the package change: stop every old process of ours, start the new binary, verify; 1 = it did not work (never a package rollback)
  echo 'nginx estaba en ejecución antes: se detienen todos los procesos nginx antiguos (master y workers) y se arranca el binario nuevo:'
  if ! stop_old; then nginx_snap; echo 'ERROR: no se han podido detener estos procesos nginx antiguos:' "$(echo $(c_all))"; echo 'La comprobación de la configuración (nginx -t) ha pasado, así que no se ha revertido nada: soluciónalo a mano (kill -9 PID para los procesos antiguos y luego systemctl start nginx, service nginx start o nginx).'; return 1; fi
  if ! start_new; then echo 'ERROR: no se ha podido arrancar nginx con el binario nuevo (revisa el log de errores de nginx).'; foreign_hint; echo 'La comprobación de la configuración (nginx -t) ha pasado, así que no se ha revertido nada: soluciónalo a mano (kill -9 PID para los procesos antiguos y luego systemctl start nginx, service nginx start o nginx).'; return 1; fi
  I=0; while ! verify_new && [ "$I" -lt 10 ]; do sleep 1; I=$((I+1)); done
  if verify_new; then
    echo 'OK: el master de nginx usa el binario instalado y todos los workers dependen de él. PID(s) del master:' "$(echo $(c_masters))"
    "$NGXBIN" -v 2>&1
    return 0
  fi
  echo 'ERROR: nginx no está sirviendo con el binario nuevo:' "$WHY"; foreign_hint; echo 'La comprobación de la configuración (nginx -t) ha pasado, así que no se ha revertido nada: soluciónalo a mano (kill -9 PID para los procesos antiguos y luego systemctl start nginx, service nginx start o nginx).'
  return 1
}

# 1. nginx-repos.clouding.io.gpg + nginx-repos.clouding.io.list
mkdir -p /usr/share/keyrings
if command -v curl >/dev/null 2>&1; then curl -fsSL https://nginx-repos.clouding.io/nginx-repos.clouding.io.gpg -o /usr/share/keyrings/nginx-repos.clouding.io.gpg.new
else wget -q -O /usr/share/keyrings/nginx-repos.clouding.io.gpg.new https://nginx-repos.clouding.io/nginx-repos.clouding.io.gpg; fi
mv /usr/share/keyrings/nginx-repos.clouding.io.gpg.new /usr/share/keyrings/nginx-repos.clouding.io.gpg && chmod 644 /usr/share/keyrings/nginx-repos.clouding.io.gpg
cat > /etc/apt/sources.list.d/nginx-repos.clouding.io.list <<'NGINXREPOS_EOF'
# nginx-repos.clouding.io: nginx (fixed) - Ubuntu 22.04 LTS (Jammy)
deb [arch=amd64 signed-by=/usr/share/keyrings/nginx-repos.clouding.io.gpg] https://nginx-repos.clouding.io/ubuntu jammy fixed
NGINXREPOS_EOF
apt-get update

# 2. Actualizaciones previstas (only already installed packages)
PKGS=$(dpkg-query -W -f='${db:Status-Abbrev} ${Package}\n' 'nginx*' 'libnginx-mod*' 2>/dev/null | awk '$1 ~ /^ii/ {print $2}' | sort -u)
[ -n "$PKGS" ] || { echo 'No hay paquetes nginx instalados: no hay nada que actualizar.'; exit 0; }
OLDVERS=$(dpkg-query -W -f='${Package}=${Version} ' $PKGS)
show_rollback() {
  echo "  apt-get install --allow-downgrades $OLDVERS"
}
SIM=$(apt-get -s -o Dpkg::Options::=--force-confold install --only-upgrade --no-remove --no-install-recommends $PKGS 2>&1) || { echo "$SIM"; echo 'apt no puede actualizar estos paquetes sin eliminar nada o sin conflictos: se cancela, no se ha cambiado nada.'; exit 1; }
if echo "$SIM" | grep -qE "^(Remv|Purg) "; then echo "$SIM" | grep -E "^(Remv|Purg) "; echo 'apt eliminaría paquetes: se cancela, no se ha cambiado nada.'; exit 1; fi
DOWN=0
echo "$SIM" | sed -n "s/^Inst \([^ ]*\) \[\([^]]*\)\] (\([^ ]*\) .*/\1 \2 \3/p" > /tmp/nginx-repos-plan.$$
while read -r PKG OLD NEW; do if dpkg --compare-versions "$NEW" lt "$OLD"; then echo "DOWNGRADE $PKG $OLD -> $NEW"; DOWN=1; fi; done < /tmp/nginx-repos-plan.$$
[ "$DOWN" = 0 ] || { rm -f /tmp/nginx-repos-plan.$$; echo 'apt bajaría de versión paquetes: se cancela, no se ha cambiado nada.'; exit 1; }
if [ ! -s /tmp/nginx-repos-plan.$$ ]; then rm -f /tmp/nginx-repos-plan.$$; echo 'Todo está ya actualizado.'; exit 0; fi
echo 'Actualizaciones previstas:'; cat /tmp/nginx-repos-plan.$$; rm -f /tmp/nginx-repos-plan.$$

# 3. upgrade
set_ourbins
census 'Procesos nginx en ejecución antes del cambio de paquetes (PID, PID padre, binario - ? = ilegible -, título):'
nginx_snap; AMB=$(c_amb)
if [ -n "$AMB" ]; then echo 'ERROR: hay un master de nginx en ejecución cuyo binario no se puede leer y cuyo título no indica ninguna ruta, y en este equipo hay otro binario de nginx, así que no se puede saber de quién es. No se ha cambiado nada. Detén ese nginx tú mismo y vuelve a ejecutar este script. PID(s):' "$(echo $AMB)"; exit 1; fi
nginx_running && WAS_RUNNING=1   # anything of OUR nginx running now? then the new binary must serve afterwards
RECPIDS=$(echo $(c_all))
if ! apt-get -y -o Dpkg::Options::=--force-confold install --only-upgrade --no-remove --no-install-recommends $PKGS; then echo 'La actualización de paquetes ha fallado. Para volver atrás, ejecuta:'; show_rollback; exit 1; fi

# 4. nginx -t + make the new binary serve
census 'Procesos nginx después del cambio de paquetes (PID, PID padre, binario - ? = ilegible -, título):'
echo 'Comprobando la configuración de nginx y, si nginx estaba en ejecución, haciendo que sirva el binario nuevo'
FAILED=0
if [ -x "$NGXBIN" ]; then
  if "$NGXBIN" -t; then
    if [ "$WAS_RUNNING" = 1 ]; then serve_new || exit 1
    else echo 'nginx no estaba en ejecución antes: no se arranca.'; fi
  else FAILED=1; fi
fi
if [ "$FAILED" != 0 ]; then echo 'La comprobación de la configuración de nginx (nginx -t) ha fallado con los paquetes nuevos. Para volver atrás, ejecuta:'; show_rollback; exit 1; fi
echo 'Hecho.'

El script solo actualiza los paquetes nginx que ya están instalados (nombres que empiezan por nginx o libnginx-mod). Nunca instala paquetes nuevos, nunca elimina paquetes y nunca hace downgrade: primero simula la actualización y se detiene si apt fuera a eliminar o bajar de versión algo. Se conservan los ficheros de configuración existentes. Después comprueba la configuración (nginx -t). Si nginx estaba en ejecución, detiene todos los procesos nginx antiguos (master y workers: una recarga dejaría en memoria el código antiguo y vulnerable), arranca nginx con el binario nuevo y comprueba que el master usa el binario instalado y todos los workers dependen de él; si nginx no estaba en ejecución, no lo arranca. Solo se toca el nginx de este paquete: los procesos de otros programas derivados de nginx (openresty, tengine, tu propia compilación) se listan como ajenos y no se tocan. Si no hay nada instalado, o todo está ya actualizado, lo indica y termina. Si falta una herramienta de descarga (curl o wget), los certificados de CA o, en APT antiguo, apt-transport-https, el script instala primero exactamente eso desde los repositorios propios de tu distribución y muestra lo que ha instalado; si no se pueden instalar, se detiene antes de cambiar nada.