Skip to content

webp: NGINX WebP module


You can install this module in any RHEL-based distribution, including, but not limited to:

  • RedHat Enterprise Linux 7, 8, 9
  • CentOS 7, 8, 9
  • AlmaLinux 8, 9
  • Rocky Linux 8, 9
  • Amazon Linux 2 and Amazon Linux 2023
yum -y install
yum -y install nginx-module-webp

Enable the module by adding the following at the top of /etc/nginx/nginx.conf:

load_module modules/;

This document describes nginx-module-webp v0.1.1.5 released on Dec 30 2019.

Webp is new (and smaller) image format. This module will convert jpg/png image on fly and send webp response.


Under development. To be continued.

Configuration directives


  • syntax: webp
  • context: location

Enables or disables module.


location ~ ".jpg" { webp; }

$ curl -SLIXGET -H "accept:image/webp"

HTTP/1.1 200 OK

Server: nginx/1.13.12

Date: Wed, 25 Apr 2018 10:16:45 GMT

Content-Length: 223980

Last-Modified: Wed, 25 Apr 2018 10:16:45 GMT

Connection: keep-alive

Content-Type: image/webp

$ curl -SLIXGET -H "accept:image/*"

HTTP/1.1 200 OK

Server: nginx/1.13.12

Date: Wed, 25 Apr 2018 10:17:53 GMT

Content-Length: 325991

Last-Modified: Wed, 18 Apr 2018 19:55:14 GMT

Connection: keep-alive

Content-Type: image/jpeg


As webp convertion takes some CPU usage I recommend to use some kind of caching of nginx responses, like Varnish.


You may find additional configuration tips and documentation for this module in the GitHub repository for nginx-module-webp.