Webinoly is just the perfect tool for NGINX experts. Give it a try!
0 votes
224 views
by Rookie
closed by

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;

}

Welcome to the Community site for Webinoly.

Our Optimized LEMP Web Server is a powerful set of commands for doing just about anything you could wish.

With Webinoly you can set up your NGINX web server in just one step.

* * * * * * *

To report a bug, please create a new issue on GitHub or ask a question here with the bug tag.
Webinoly Support Paypal Donations

PayPal · GitHub Sponsors · Bitcoin

It is very important that any visitor to the site read the disclaimer, terms of use and privacy and legal statement before start browsing.

...