How to install sw-nginx-module-cors on Ubuntu

Correct CORS for NGINX, including preflight and Vary

Vendor: GetPageSpeed https://github.com/GetPageSpeed/ngx_cors

Availability

Compare package tracks by distribution and architecture. Checkmarks show the architectures available in each repository channel.

Distro Channel amd64 Version
Ubuntu 26.04 (resolute) Base 1.30.6.1+1.0.0+p18.0.82.1.t261027.1716
Ubuntu 24.04 (noble) Base 1.30.6.1+1.0.0+p18.0.82.1.t261027.1716
Ubuntu 22.04 (jammy) Base 1.30.6.1+1.0.0+p18.0.82.1.t261027.1716
Ubuntu 20.04 (focal) Base 1.30.6.1+1.0.0+p18.0.82.1.t261027.1716

Description

CORS module for NGINX that handles the parts the add_header recipe gets wrong. Preflight OPTIONS requests are answered internally and never reach the upstream. Origin matching supports exact lists, wildcard subdomains and regular expressions, with Access-Control-Allow-Credentials refused at configuration time when it would be paired with a wildcard origin the browser rejects. Access-Control-* headers are emitted on error responses too, so a failing request surfaces the real status instead of an opaque CORS failure. Vary: Origin is emitted whenever the response depends on the request origin, which keeps shared caches and CDNs correct. Premium module by GetPageSpeed.

Built for Ubuntu.

Install

Base Ubuntu 20.04, 22.04, 24.04, 26.04

sw-nginx-module-cors on Ubuntu 20.04 (focal), 22.04 (jammy), 24.04 (noble), 26.04 (resolute)

curl -fsSL https://extras.getpagespeed.com/release-latest.deb -o /tmp/getpagespeed-release.deb
sudo apt-get install -y /tmp/getpagespeed-release.deb
rm /tmp/getpagespeed-release.deb
sudo apt-get update
sudo apt-get install -y sw-nginx-module-cors

Package downloads require an active GetPageSpeed subscription — one repository for sw-nginx-module-cors and thousands more packages for Ubuntu.

Subscribe — from $10/mo

Other releases and channels: use the setup wizard.

Frequently asked questions

How do I install sw-nginx-module-cors on Ubuntu?

Add the GetPageSpeed repository, then install the sw-nginx-module-cors package with your system package manager.

Which Ubuntu versions is sw-nginx-module-cors available for?

sw-nginx-module-cors is available for Ubuntu 20.04, 22.04, 24.04, 26.04.

Subscribe