Hi,
I'm tring to config local WebP by Smush Pro for my wordpress. The Smush Pro requires the below rules to be inserted in the server context of configuration file. However I couldn't complete it.
When I inserted the rules in nginx.conf, I got the error:
"server" directive is not allowed here in /etc/nginx/nginx.conf
When I inserted the rules inside "server { }" in custom-nginx.conf, I got the below error:
"server" directive is not allowed here in /var/www/domain.com/custom-nginx.conf
When I inserted the rules without "server { }" in custom-nginx.conf, I got no error. However when I double check with the Smush Pro, it said that "rules hasn't been applied yet"
Nginx was relad/restart every time I insert the code.
The code is below, please help me as I don't know what to do to fix it.
location ~* "wp-content\/(uploads\/)(.*.(?:png|jpe?g))" {
add_header Vary Accept;
set $image_path $2;
if (-f "/var/www/mydomain.com/htdocs/wp-content/smush-webp/disable_smush_webp") {
break;
}
if ($http_accept !~* "webp") {
break;
}
try_files /wp-content/smush-webp/$image_path.webp $uri =404;
}