Wp smush pro - nginx + phpfpm

I have Nginx + phpfpm , i dont install apache…

i need put this code, but , when i put, nothing happend

BEGIN SMUSH-WEBP

location ~* "wp-content/(uploads/)(..(?:png|jpe?g))" {
add_header Vary Accept;
set $image_path $2;
if (-f “/home/mydiretory/web/mydomain/public_html/wp-content/smush-webp/disable_smush_webp”) {
break;
}
if ($http_accept !~
“webp”) {
break;
}
expires max;
try_files /wp-content/smush-webp/$image_path.webp $uri =404;
}

END SMUSH-WEBP

the wp smush pro to not recognize…
ive try create a new wordpress template…put de code and nothing happend too…

gd

GD Support => enabled
GD headers Version => 2.2.5
GD library Version => 2.2.5
FreeType Support => enabled
FreeType Linkage => with freetype
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
PNG Support => enabled
WBMP Support => enabled
XPM Support => enabled
XBM Support => enabled
WebP Support => enabled
BMP Support => enabled
TGA Read Support => enabled

someone know how do i install ?
so thank you…

First remove the image out off:

ive created a wordpress-webp.tpl
ive try remove this code and put the code of wp smush pro, continue…no reconigzing…
what im doing wrong…

There are two templates, one finished in .tpl (http) and one finished in .stpl (https). You must modify both of them.

If you have created a new template, you must select it in the web configuration in hestiacp.

when i remove this code

location / {
try_files $uri $uri/ /index.php?$args;
location ~* ^.+.(ogg|ogv|svg|svgz|swf|eot|otf|woff|woff2|mov|mp3|mp4|webm|flv|ttf|rss|atom|jpg|gif|ico|bmp|mid|midi|wav|rtf|css|js|jar)$ {
expires 30d;
fastcgi_hide_header “Set-Cookie”;
}

nginx fail…

im tryin this…

BEGIN SMUSH-WEBP

location ~* "wp-content/(uploads/)(..(?:png|jpe?g))" {
add_header Vary Accept;
set $image_path $2;
if (-f “/home/mydiretory/web/mysite/public_html/wp-content/smush-webp/disable_smush_webp”) {
break;
}
if ($http_accept !~
“webp”) {
break;
}
expires max;
try_files /wp-content/smush-webp/$image_path.webp $uri =404;
}

END SMUSH-WEBP

location / {
try_files $uri $uri/ /index.php?$args;
location ~* ^.+.(ogg|ogv|svg|svgz|swf|eot|otf|woff|woff2|mov|mp3|mp4|webm|flv|ttf|rss|atom|jpg|jpeg|gif|png|webp|ico|bmp|mid|midi|wav|rtf|css|js|jar)$ {
expires 30d;
fastcgi_hide_header “Set-Cookie”;
}

but on wordpress do not recognizing

still no luck on a fix for this issue?

Am also running Nginx + Php-fpm setup and I can’t seem to get it to work either.

  1. I tried removing lines below from nginx.config but nginx fails;
    location / {
    try_files $uri $uri/ /index.php?$args;
    location ~* ^.+.(ogg|ogv|svg|svgz|swf|eot|otf|woff|woff2|mov|mp3|mp4|webm|flv|ttf|rss|atom|jpg|jpeg|gif|png|webp|ico|bmp|mid|midi|wav|rtf|css|js|jar)$ {
    expires 30d;
    fastcgi_hide_header “Set-Cookie”;
    }

  2. I add the code from Smush within the /home/user/conf/web/domain/nginx.conf still no luck.

  3. I created smush-webp-main-context.conf file and tried to include it in /home/user/conf/web/domain/nginx.conf still no luck.

Has anyone got the Smush to work with HestiaCP

Hello :grinning:

I got working for plugin Converter for Media

The check for $http_accept only worked outside of location / {} block

This is the wordpress template for .tpl (should adapt for .stpl later). You should adapt for Smush from there

If there is a better way idk

#=========================================================================#
# Default Web Domain Template                                             #
# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS   #
# https://docs.hestiacp.com/admin_docs/web.html#how-do-web-templates-work #
#=========================================================================#

server {
    listen      %ip%:%web_port%;
    server_name %domain_idn% %alias_idn%;
    root        %docroot%;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/%domain%.log combined;
    access_log  /var/log/nginx/domains/%domain%.bytes bytes;
    error_log   /var/log/nginx/domains/%domain%.error.log error;

    include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;

    # BEGIN Converter for Media
    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 = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location ~ /\.(?!well-known\/) {
        deny all;
        return 404;
    }

    location / {
        try_files $uri $uri/ /index.php?$args;
        location ~* ^.+\.(ogg|ogv|svg|svgz|swf|eot|otf|woff|woff2|mov|mp3|mp4|webm|flv|ttf|rss|atom|jpg|jpeg|gif|png|webp|ico|bmp|mid|midi|wav|rtf|css|js|jar)$ {
            expires 30d;
            fastcgi_hide_header "Set-Cookie";

            ############ WordPress HARDEN AND WEBP ####################

            location ~ /wp-content/(?<path>.+)\.(?<ext>jpe?g|png|gif|webp)$ {
                # webp rewrite rules
                add_header Vary "Accept-Encoding";
                add_header "Access-Control-Allow-Origin" "*";
                add_header Cache-Control "public, no-transform";
                access_log off;
                log_not_found off;
                expires max;
                try_files
                    /wp-content/uploads-webpc/$path.$ext$ext_avif
                    /wp-content/uploads-webpc/$path.$ext$ext_webp
                    $uri =404;
            }
            # END Converter for Media

        }
        
        location ~* /(?:uploads|files)/.*.php$ {
            deny all;
            return 404;
        }
        
        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            try_files $uri =404;
            fastcgi_pass %backend_lsnr%;
            fastcgi_index index.php;
            include /etc/nginx/fastcgi_params;
            include %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf*;
            if ($request_uri ~* "/wp-admin/|/wp-json/|wp-.*.php|xmlrpc.php|index.php|/store.*|/cart.*|/my-account.*|/checkout.*") {
                set $no_cache 1;
            }
            if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|woocommerce_items_in_cart|woocommerce_cart_hash|PHPSESSID") {
                set $no_cache 1;
            }
        }
    }

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location /vstats/ {
        alias   %home%/%user%/web/%domain%/stats/;
        include %home%/%user%/web/%domain%/stats/auth.conf*;
    }

    include /etc/nginx/conf.d/phpmyadmin.inc*;
    include /etc/nginx/conf.d/phppgadmin.inc*;
    include %home%/%user%/conf/web/%domain%/nginx.conf_*;
}