Trying to use CompressX rewrite rules for nginx. Created a file inside common folder and added it in the sites-available domain config but rewrite rules are not working.
Also getting this Error Invalid regular expression: //wp-content/(?.+).(?jpe?g|png|gif|webp)$/: Invalid group i fixed it with this rule location ~ /wp-content/(?<path>.+).(?<ext>jpe?g|png|gif)$ { but no luck.
`# BEGIN CompressX
set $ext_avif ".avif";
if ($http_accept !~* "image/avif") {
set $ext_avif "";
}
set $ext_webp ".webp";
if ($http_accept !~* "image/webp") {
set $ext_webp "";
}
location ~ /wp-content/(?.+)\.(?jpe?g|png|gif|webp)$ {
add_header Vary Accept;
add_header Cache-Control "private";
expires 365d;
try_files
/wp-content/compressx-nextgen/$path.$ext$ext_avif
/wp-content/compressx-nextgen/$path.$ext$ext_webp
$uri = 404;
}
# END CompressX`
https://compressx.io/docs/config-nginx-htaccess/