WebP support with NGINX

Discussion in 'Plesk Automation Suggestions and Feedback' started by P_heck, Jul 25, 2016.

  1. P_heck

    P_heck Kilo Poster

    Messages:
    60
    Plesk version 12.5.30 Update #40

    I would like to enable WebP support on my hosted Wordpress sites using the Optimus plugin. To do so, it is required to force NGINX to send the right headers.

    Unfortanately, the first solution described in the support document of Optimus couldn't be used due to incompatibility with the used Nexusthemes Template framework. So I tried to configure the 2nd solution, to tell NGINX to produce the header.

    Unfortunately, I can't add the below directives to the custom NGINX configuration in Plesk Panel as it always complains about it.

    Code:
    # http config block
    map $http_accept $webp_ext {
        default "";
        "~*webp" ".webp";
    }
    
    # server config block
    location ~* ^/wp-content/.+\.(png|jpg)$ {
        add_header Vary Accept;
        try_files $uri$webp_ext $uri =404;
    }
    Anyone has any idea, how I can enable WebP support within a Plesk NGINX based installation?

    Cheers Peter
     

Share This Page