Guides 11792 Published by

Fedora ships its own older Nginx package, which is fine for most sites but blocks newer features like HTTP/3 and upstream proxy directives. To get the bleeding‑edge mainline build, you add nginx.org’s Fedora‑specific repository by writing a repo file that points at the “mainline” directory and then run `dnf install nginx`. After confirming the version with `nginx -v`, you can rely on normal `dnf upgrade` commands to keep the server up‑to‑date, because the added repo feeds new releases directly. Finally, restart systemd’s nginx service and test a simple request to ensure everything is running correctly.



How to Enable Nginx Mainline on Fedora Linux

Fedora ships with an older, stable release of Nginx in its official repos. If you need the latest features or performance tweaks from the mainline branch, you’ll have to point your system at Nginx’s own repository and pull that package instead.

Why the default Fedora repo isn’t what you want

When I first upgraded a server from Fedora 34 to 35, the dnf install nginx command pulled in version 1.18 – the last “stable” release that the Fedora team ships. That’s fine for many sites, but if you’re trying to use the HTTP/3 module or the new upstream proxy directives, you’ll find yourself stuck. The default repo is intentionally conservative; it doesn’t get the bleeding‑edge changes until a later update cycle.

Add Nginx’s official repository

The easiest way to get the mainline package is to add their Fedora‑specific repo file:

sudo tee /etc/yum.repos.d/nginx.repo > /dev/null <<'EOF'
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/fedora/$releasever/mainline/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
EOF
Why this matters:

The baseurl points directly at the folder that hosts the mainline RPMs for whatever Fedora release you’re on. Without it, dnf keeps looking in Fedora’s default mirrors and will keep giving you the older 1.18 build.

Install the mainline package
sudo dnf install nginx

You’ll see the output mention nginx-<version>.el8.x86_64. That’s the mainline version – usually something like 1.26 or newer, depending on when you run the command.

Why this matters:

dnf resolves dependencies against the repo you just added, so it pulls in the correct binary and any required libraries. If you had the old repo enabled at the same time, you might end up with a mix‑and‑match of packages that don’t play nicely together.

Verify you’re on mainline
nginx -v

The output should look like:

nginx version: nginx/1.26.x

If you still see an older number, double‑check the repo file or try sudo dnf clean all before reinstalling.

Why this matters:

Seeing the right version guarantees that the features you’re after are actually present in your binary. It also lets you confirm that you’re not accidentally running a cached old package.

Keep it updated

Fedora’s dnf will automatically update Nginx when you run:

sudo dnf upgrade nginx

Because we added the official repo, any new mainline release will be pulled in. If you want to stay on the bleeding edge, just keep running upgrades – no extra flags required.

The mainline branch receives security patches and performance improvements more quickly than Fedora’s stable stream. Staying up‑to‑date means fewer surprises when a vulnerability is discovered or a bug gets fixed upstream.

A quick sanity check

After installing, don’t forget to restart the service so that systemd picks up any changes:

sudo systemctl restart nginx

Then test with curl -I http://localhost to confirm it’s still serving pages. If you hit a 502 or 504, double‑check your config and make sure no modules are missing.

That’s all there is to it. You’ve swapped Fedora’s conservative Nginx for the bleeding‑edge mainline build with just a few commands and a repo tweak.