Welcome to Centmin Mod Community
Become a Member

Wordpress WEBP is not served on Wordpress

Discussion in 'Blogs & CMS usage' started by selcukv, Jun 12, 2020.

Tags:
  1. selcukv

    selcukv New Member

    22
    5
    3
    Sep 21, 2018
    Ratings:
    +6
    Local Time:
    3:22 AM
    nginx/1.17.8
    Ver 15.1 Distrib 10.3.22-MariaDB
    Hi there,

    I remember that I had succeeded to make it work some time ago, on my deleted server.

    Followed the guide here: Nginx Serving WebP Images Conditionally Demo but this time it didn't work. I was on Cloudflare Free Plan and deactivated Proxy before I started.

    Here is my virtual host conf file:


    Code:
    #x# HTTPS-DEFAULT
     server {
       listen 80;
       server_name mydomain.com www.mydomain.com;
       return 301 https://www.mydomain.com$request_uri;
       include /usr/local/nginx/conf/staticfiles.conf;
     }
    
     server {
      
       listen 443 ssl http2;
       server_name mydomain.com;
       return 301 https://www.mydomain.com$request_uri;
       include /usr/local/nginx/conf/ssl/mydomain.com/mydomain.com.crt.key.conf;
       include /usr/local/nginx/conf/ssl_include.conf;
     }
    
    server {
      listen 443 ssl http2 reuseport;
      server_name www.mydomain.com;
    
      include /usr/local/nginx/conf/ssl/mydomain.com/mydomain.com.crt.key.conf;
      include /usr/local/nginx/conf/ssl_include.conf;
    
      # cloudflare authenticated origin pull cert community.centminmod.com/threads/13847/
      #ssl_client_certificate /usr/local/nginx/conf/ssl/cloudflare/mydomain.com/origin.crt;
      #ssl_verify_client on;
      http2_max_field_size 16k;
      http2_max_header_size 32k;
      http2_max_requests 50000;
      # mozilla recommended
      ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS;
      ssl_prefer_server_ciphers   on;
      #add_header Alternate-Protocol  443:npn-spdy/3;
    
      # before enabling HSTS line below read centminmod.com/nginx_domain_dns_setup.html#hsts
      add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
      add_header X-Frame-Options SAMEORIGIN;
      add_header X-Xss-Protection "1; mode=block" always;
      add_header X-Content-Type-Options "nosniff" always;
      #add_header Referrer-Policy "strict-origin-when-cross-origin";
      add_header Feature-Policy "accelerometer 'none'; camera 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; payment 'none'; usb 'none'";
      #spdy_headers_comp 5;
      ssl_buffer_size 1369;
      ssl_session_tickets on;
     
      # enable ocsp stapling
      resolver 8.8.8.8 8.8.4.4 1.1.1.1 1.0.0.1 valid=10m;
      resolver_timeout 10s;
      ssl_stapling on;
      ssl_stapling_verify on;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/mydomain.com/log/access.log combined buffer=256k flush=5m;
      error_log /home/nginx/domains/mydomain.com/log/error.log;
    
      include /usr/local/nginx/conf/autoprotect/mydomain.com/autoprotect-mydomain.com.conf;
      root /home/nginx/domains/mydomain.com/public;
      # uncomment cloudflare.conf include if using cloudflare for
      # server and/or vhost site
      #include /usr/local/nginx/conf/cloudflare.conf;
      include /usr/local/nginx/conf/503include-main.conf;
      include /usr/local/nginx/rocket-nginx/default.conf;
    
      include /usr/local/nginx/conf/mydomain-yonlendirmeler.conf;
    
     
      #include /usr/local/nginx/conf/wpincludes/mydomain.com/wpcacheenabler_mydomain.com.conf;
      #include /usr/local/nginx/conf/wpincludes/mydomain.com/wpsupercache_mydomain.com.conf;
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/wpincludes/mydomain.com/rediscache_mydomain.com.conf; 
    
      location / {
      include /usr/local/nginx/conf/503include-only.conf;
     
    
      # Enables directory listings when index file not found
      #autoindex  on;
    
      # for wordpress super cache plugin
      #try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?q=$uri&$args;
    
      # for wp cache enabler plugin
      # try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args; 
    
      # Wordpress Permalinks
      try_files $uri $uri/ /index.php?q=$uri&$args;
    
      # Nginx level redis Wordpress
      # https://community.centminmod.com/posts/18828/
      #try_files $uri $uri/ /index.php?$args;
    
      }
    
      #wp rocket
      #try_files $uri $uri/ /index.php?$args;
    
    location ~* /(wp-login\.php) {
        limit_req zone=xwplogin burst=1 nodelay;
        #limit_conn xwpconlimit 30;
        auth_basic "Private";
        auth_basic_user_file /home/nginx/domains/mydomain.com/htpasswd_wplogin;   
        include /usr/local/nginx/conf/php.conf;
        
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    location ~* /(xmlrpc\.php) {
        limit_req zone=xwprpc burst=45 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php.conf;
        
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    location ~* /wp-admin/(load-scripts\.php) {
        limit_req zone=xwprpc burst=5 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php.conf;
        
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    # webp extension support if you are converting /uploads images to webp
    location ~ ^/wp-content/uploads {
      #pagespeed off;
      #pagespeed unplugged;
      #autoindex on;
      #add_header X-Robots-Tag "noindex, nofollow";
      location ~* ^/wp-content/uploads/(.+/)?(.+)\.(png|jpe?g)$ {
       expires 30d;
       add_header Vary "Accept";
       add_header Cache-Control "public, no-transform";
       try_files $uri$webp_extension $uri =404;
      }
    }
    
    
      include /usr/local/nginx/conf/wpincludes/mydomain.com/wpsecure_mydomain.com.conf;
      include /usr/local/nginx/conf/php.conf;
     
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/php-rediscache.conf;
      include /usr/local/nginx/conf/pre-staticfiles-local-mydomain.com.conf;
      include /usr/local/nginx/conf/pre-staticfiles-global.conf;
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
    
    I can view the Webp files by their URL without a problem, but when it comes to serving, there's a problem.
     
  2. eva2000

    eva2000 Administrator Staff Member

    44,417
    10,144
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,692
    Local Time:
    10:22 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
  3. selcukv

    selcukv New Member

    22
    5
    3
    Sep 21, 2018
    Ratings:
    +6
    Local Time:
    3:22 AM
    nginx/1.17.8
    Ver 15.1 Distrib 10.3.22-MariaDB
    Thank you for the kind reply, George.

    I was going to ask "So, a quick question, even if I use their DNS service - no proxy or nothing else, can't I use WEBP?" by taking a screenshop of my CF configuration. There I realized that I forgot to disable Proxy for www. :)

    https://imgur.com/a/I19sReq

    It works perfectly now. The reason why I don't have some JPEGs is some of the files were neglected because of the size, that's why they don't have WEBP version.

    https://imgur.com/a/kmonsR7

    Thank you so much for you help again!