• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question How to make "sites-available" under CentOS 8, Plesk Obsidian and Nginx

fd_paz

Basic Pleskian
Hi,
I have the latest version of Obsidian installed on CentOS 8 and I use Nginx.
Unfortunately, I cannot configure "/etc/nginx/sites-available" for Smush pro. I can't find right tutorial on the net.

I should insert the commands below in Nginx:

Code:
# BEGIN SMUSH-WEBP
location ~* "wp-content\/(uploads\/)(.*.(?:png|jpe?g))" {
  add_header Vary Accept;
  set $image_path $2;
  if (-f "/var/www/vhosts/domain.net/httpdocs/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

Could someone kindly explain me step by step the commands to integrate this data in Nginx and above all tell me how I can configure "/etc/nginx/sites-available"?

Thanks
 
Last edited by a moderator:
Have you tried to add this config to Additional nginx directives for your domain?
 
Thanks.
And to apply rules on individual domains how should I do?
I tried to copy and paste the commands under "Adeitional nginx directives" in "Apache & nginx Settings" under the domain in question, but it didn't work.
 
Hi @IgorG,

Could you please tell me to apply the rules on individual domains how do I do it?

Unfortunately I can't find the correct instructions to create "sites-available" for Nginx installed in Plesk on CentOS 8.
It seems that "sites-available" is a configuration for Ubuntu.
Could someone clarify this please?

Thanks
 
SInce you're using Plesk, forget whatever is being mentioned about sites-available/enabled

It should work if you paste it in the "Additional NGINX Directives." Do you have another rule taking precedent? Ie, serve static files via NGINX
 
I have included the codes in the "Additional NGINX Directives" and basically I see that a directory "/httpdocs/wp-content/smush-webp" has been created with the webp files, but I don't understand why in the plugin options in WordPress backend there is the message that "Status: Server configurations haven't been applied yet. Make configurations below to start serving images in WebP format."
The option "Serve static files directly by nginx" is active.

All codes in "Additional NGINX Directives" is:
Code:
gzip on;
gzip_disable "MSIE [1-6]\\.(?!.*SV1)";
gzip_proxied any;
gzip_comp_level 5;
gzip_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml;
gzip_vary on;

if (!-e $request_filename) {
    set $test P;
}
if ($uri !~ ^/(plesk-stat|webstat|webstat-ssl|ftpstat|anon_ftpstat|awstats-icon|internal-nginx-static-location)) {
    set $test "${test}C";
}
if ($test = PC) {
    rewrite ^/(.*)$ /index.php?$1;
}

location ~* \.(css|js)$ {
    gzip_vary on;
    expires 30d;
}
location ~* \.(ac3|atom|avi|bmp|bz2|css|csv|cue|dat|doc|docx|dts|eot|exe|flv|gif|gz|htm|html|ico|img|iso|jpeg|jpg|js|map|mid|midi|mkv|mp3|mp4|mpeg|mpg|m4a|ogg|ogv|otf|pdf|png|ppt|pptx|qt|rar|rm|rss|rtf|svg|svgz|swf|tar|tgz|ttf|txt|wav|webp|woff|woff2|xls|xlsx|zip)$ {
    gzip_vary on;
    expires max;
    log_not_found off;
}

# BEGIN SMUSH-WEBP
location ~* "wp-content\/(uploads\/)(.*.(?:png|jpe?g))" {
    add_header Vary Accept;
    set $image_path $2;
    if (-f "/var/www/vhosts/domain.com/httpdocs/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

Thanks
 
Hi. Did you find a solution to this? I am at the same point!

I have included the codes in the "Additional NGINX Directives" and basically I see that a directory "/httpdocs/wp-content/smush-webp" has been created with the webp files, but I don't understand why in the plugin options in WordPress backend there is the message that "Status: Server configurations haven't been applied yet. Make configurations below to start serving images in WebP format."
The option "Serve static files directly by nginx" is active.

All codes in "Additional NGINX Directives" is:
Code:
gzip on;
gzip_disable "MSIE [1-6]\\.(?!.*SV1)";
gzip_proxied any;
gzip_comp_level 5;
gzip_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml;
gzip_vary on;

if (!-e $request_filename) {
    set $test P;
}
if ($uri !~ ^/(plesk-stat|webstat|webstat-ssl|ftpstat|anon_ftpstat|awstats-icon|internal-nginx-static-location)) {
    set $test "${test}C";
}
if ($test = PC) {
    rewrite ^/(.*)$ /index.php?$1;
}

location ~* \.(css|js)$ {
    gzip_vary on;
    expires 30d;
}
location ~* \.(ac3|atom|avi|bmp|bz2|css|csv|cue|dat|doc|docx|dts|eot|exe|flv|gif|gz|htm|html|ico|img|iso|jpeg|jpg|js|map|mid|midi|mkv|mp3|mp4|mpeg|mpg|m4a|ogg|ogv|otf|pdf|png|ppt|pptx|qt|rar|rm|rss|rtf|svg|svgz|swf|tar|tgz|ttf|txt|wav|webp|woff|woff2|xls|xlsx|zip)$ {
    gzip_vary on;
    expires max;
    log_not_found off;
}

# BEGIN SMUSH-WEBP
location ~* "wp-content\/(uploads\/)(.*.(?:png|jpe?g))" {
    add_header Vary Accept;
    set $image_path $2;
    if (-f "/var/www/vhosts/domain.com/httpdocs/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

Thanks
 
Solved...ish. If you serve the images via the CDN and not locally, images are automatically served as WebP. HTH.
 
Back
Top