Update NGINX with code for a WordPress Plugin
Budget: $30 – $250 USD
I need to install some NGINX code on my server for a plugin to work; however, my server company won't do it for me. I need someone to do this and also show me how to do it so we can do it when we build new sites.
The plugin is WPMUDEV's Smush Pro. We're trying to get the Local WebP function to work. My server is Apache with NGINX. We've tried adding to htaccess automatically and manually, but it doesn't work so we need to do the NGINX.
Local WebP Installation Overview: https://wpmudev.com/blog/local-webp-support-smush/
Server Instructions and code:
Insert the following in the server context of your configuration file (usually found in /etc/nginx/sites-available). "The server context" refers to the part of the configuration that starts with "server {" and ends with the matching "}".
Copy the generated code found below and paste it inside your server block.
Reload NGINX.
Code:
# BEGIN SMUSH-WEBP
location ~* "wp-content\/(uploads\/)(.*.(?:png|jpe?g))" {
add_header Vary Accept;
set $image_path $2;
if (-f "/home/brewfest/public_html/wp-content/smush-webp/disable_smush_webp") {
break;
}
if ($http_accept !~* "webp") {
break;
}
try_files /wp-content/smush-webp/$image_path.webp $uri =404;
}
# END SMUSH-WEBP
The plugin is WPMUDEV's Smush Pro. We're trying to get the Local WebP function to work. My server is Apache with NGINX. We've tried adding to htaccess automatically and manually, but it doesn't work so we need to do the NGINX.
Local WebP Installation Overview: https://wpmudev.com/blog/local-webp-support-smush/
Server Instructions and code:
Insert the following in the server context of your configuration file (usually found in /etc/nginx/sites-available). "The server context" refers to the part of the configuration that starts with "server {" and ends with the matching "}".
Copy the generated code found below and paste it inside your server block.
Reload NGINX.
Code:
# BEGIN SMUSH-WEBP
location ~* "wp-content\/(uploads\/)(.*.(?:png|jpe?g))" {
add_header Vary Accept;
set $image_path $2;
if (-f "/home/brewfest/public_html/wp-content/smush-webp/disable_smush_webp") {
break;
}
if ($http_accept !~* "webp") {
break;
}
try_files /wp-content/smush-webp/$image_path.webp $uri =404;
}
# END SMUSH-WEBP