I have been trying to set up Brotli compression on Nginx, but am failing at the package installation step.

In particular, when I run sudo apt install nginx-module-brotli, I get this

The following packages have unmet dependencies:
 nginx-module-brotli : Depends: nginx (= 1.17.3-2-ppa7~bionic)
E: Unable to correct problems, you have held broken packages.

However, my Nginx version seems to match

nginx -V
nginx version: nginx/1.17.3
built by gcc 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) 
built with OpenSSL 1.1.1  11 Sep 2018
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx-1.17.3/debian/debuild-base/nginx-1.17.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'

Any advice on how to fix this is appreciated. I have tried updating to the newest Nginx (1.20.x), but the same thing persists. I have also tried compiling it from scratch using THIS guide here with same results.

Edit: Per request in comments

> (base) ubuntu@host:~$ sudo apt update Hit:1
> http://us-west-2.ec2.archive.ubuntu.com/ubuntu bionic InRelease Hit:2
> http://us-west-2.ec2.archive.ubuntu.com/ubuntu bionic-updates
> InRelease                                                    Hit:3
> http://us-west-2.ec2.archive.ubuntu.com/ubuntu bionic-backports
> InRelease                                                  Get:4
> http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB] 
> Hit:5 http://ppa.launchpad.net/hda-me/nginx-stable/ubuntu bionic
> InRelease                                                     Hit:6
> http://nginx.org/packages/ubuntu bionic InRelease                     
> Hit:7 http://ppa.launchpad.net/maxmind/ppa/ubuntu bionic InRelease
> Fetched 88.7 kB in 1s (145 kB/s) Reading package lists... Done
> Building dependency tree        Reading state information... Done 47
> packages can be upgraded. Run 'apt list --upgradable' to see them.

> (base) ubuntu@host:~$ sudo apt install nginx Reading
> package lists... Done Building dependency tree        Reading state
> information... Done The following NEW packages will be installed:  
> nginx 0 upgraded, 1 newly installed, 0 to remove and 47 not upgraded.
> Need to get 877 kB of archives. After this operation, 3,074 kB of
> additional disk space will be used. Get:1
> http://nginx.org/packages/ubuntu bionic/nginx amd64 nginx amd64
> 1.20.2-1~bionic [877 kB] Fetched 877 kB in 1s (668 kB/s) Selecting previously unselected package nginx. (Reading database ... 149038
> files and directories currently installed.) Preparing to unpack
> .../nginx_1.20.2-1~bionic_amd64.deb ...
> ----------------------------------------------------------------------
> Thanks for using nginx!
> Please find the official documentation for nginx here:
> * https://nginx.org/en/docs/
> Please subscribe to nginx-announce mailing list to get the most
> important news about nginx:
> * https://nginx.org/en/support.html
> Commercial subscriptions for nginx are available on:
> * https://nginx.com/products/
> ---------------------------------------------------------------------- Unpacking nginx (1.20.2-1~bionic) ... Setting up nginx
> (1.20.2-1~bionic) ... nginx: [warn] the "ssl" directive is deprecated,
> use the "listen ... ssl" directive instead in
> /etc/nginx/sites-enabled/zdravost:22 Processing triggers for man-db
> (2.8.3-2ubuntu0.1) ... Processing triggers for ureadahead (0.100.0-21)
> ... Processing triggers for systemd (237-3ubuntu10.50) ...
  • Please edit to include the output of sudo apt update.
    – Someone
    Jan 24 at 10:53
  • @Someone Added. Jan 24 at 11:08
  • Thanks, please also add the output of sudo apt install nginx
    – Someone
    Jan 24 at 11:09
  • @Someone Added. Jan 24 at 11:12
  • @Someone Now it installed version 1.20.2 Jan 24 at 11:14

1 Answer 1


It seems like you are having two repositories which provide the same package I.e nginx. However, one of those repositories also contain, nginx-module-brotli which depends on nginx (= 1.17.3-2-ppa7, which is provided by the hda-me/nginx-stable PPA. You must remove the other PPAs which provide the same package I.e nginx because its confusing apt about which package to install. APT is mistakenly installing the wrong version. You must remove other repository, so that only one version is left. The wrong PPA here is nginx/stable which provides version: 1.20.2. The correct one is hda-me/nginx-stable which provides version: 1.17.3-2-ppa7 which is required by nginx-module-brotli.

  1. Remove the wrong PPA:

    sudo apt-add-repository --remove nginx/stable
  2. Update:

    sudo apt update
  3. Remove the wrong version of nginx:

    sudo apt remove nginx
  4. Install the correct version of nginx:

    sudo apt install nginx
  5. Install the required package:

    sudo apt install nginx-module-brotli

Alternatively, you can achieve the same using reinstalling the correct package version. However, this is NOT recommended because this may cause dependency troubles, may lead to broken packages or prevent packages from upgrading:

sudo apt install --reinstall nginx=1.17.3-2-ppa7~bionic nginx-module-brotli

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.