Update Nginx to the latest stable version on CentOS 8
Date: 2022-10-27Last modified: 2023-02-17
To address the security issue CVE-2019-20372 I needed to update the Nginx version to the current stable.
Remove the old nginx:
sudo systemctl stop nginx
sudo dnf remove nginx
sudo dnf install dnf-utils
Create the repo file:
cat <<EOF > /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
EOF
Install and enable the nginx again.
sudo yum-config-manager --enable nginx-mainline
sudo dnf install nginx
sudo systemctl start nginx
sudo systemctl start nginx