Join the community today
Register Now

Webp not work in Browser

Discussion in 'Blogs & CMS usage' started by Max, Nov 28, 2024.

  1. Max

    Max Member

    124
    5
    18
    Feb 17, 2018
    Ratings:
    +9
    Local Time:
    3:16 AM
    Please fill in any relevant information that applies to you:
    • CentOS Version: AlmaLinux 9.5
    • Centmin Mod Version Installed:140.00beta01.b171
    • Nginx Version Installed: 1.27.3 ?
    • PHP Version Installed: 8.2.26
    • Persistent Config:
    • Code:
      SET_DEFAULT_MYSQLCHARSET='utf8mb4'
      SELFSIGNEDSSL_ECDSA='y'
      PHPFINFO='y'
      PHP_OVERWRITECONF='n'
      PYTHON_INSTALL_ALTERNATIVES='y'
      MARCH_TARGETNATIVE='n'
      NGINX_ONETWOTHREE_COMPAT='y'
      GENERAL_DEVTOOLSETGCC='y'
      DEVTOOLSETTEN='n'
      DEVTOOLSETELEVEN='n'
      DEVTOOLSETTWELVE='y'
      SELFSIGNEDSSL_ECDSA='y'
      PHP_PGO_ALWAYS='y'
      PHP_PGO='y'
      PHPFINFO='y'
      PHP_OVERWRITECONF='n'
      PYTHON_INSTALL_ALTERNATIVES='y'
      DMOTD_PHPCHECK='y'
      NGINX_GEOIPTWOLITE='y'
      NGXDYNAMIC_GEOIPTWOLITE='y'
      NGINX_HPACK='y'
      NGINX_DYNAMICTLS='y'
      NGINX_PCRE_TWO='y'
      OPENSSL_VERSION='3.1.4'
      OPENSSL_VERSIONFALLBACK='3.1.4'
      OPENSSL_VERSION_OLDOVERRIDE='3.1.4'
      NGINX_NJS='y'
      NGXDYNAMIC_NJS='y'
      NGXDYNAMIC_BROTLI='y'
      NGINX_LIBBROTLI='y'
      NGINX_VIDEO='y'
      #ENABLE_MARIADBTENFOURUPGRADE='y'
      #ENABLE_MARIADBTENFIVEUPGRADE='y'
      ENABLE_MARIADBTENSIXUPGRADE='y'
      LETSENCRYPT_DETECT='y'
      ACME_DEFAULT_CA='zerossl'
      MARCH_TARGETNATIVE='n'
      AUTODETECPHP_OVERRIDE='y'
      
    • DNS over cloudflare no proxy
    I had to change my VPS from inceptionhosting to clouvider and restore the Wordpress site backup.

    but webp config not work
    Code:
    # webp extension support if you are converting /uploads images to webp
     location ~ ^/wp-content/uploads/ {
       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;
      }
    }
    
    Webp files are generat generated with webp-optimize
    Code:
    0 */1 * * * /root/tools/optimise-images/optimise-images.sh optimise-cron-age  /home/nginx/domains/mojobus.org/public/wp-content/uploads/ >/dev/null 2>&1
    everything worked on the old VPS

    or is there a better way to deliver webp now
    Any Tip
    Thanks

     
  2. eva2000

    eva2000 Administrator Staff Member

    54,126
    12,179
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,739
    Local Time:
    1:16 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Can you elaborate as to what you mean by not working? not creating .webp images or created but not being served to visitors?
     
  3. Max

    Max Member

    124
    5
    18
    Feb 17, 2018
    Ratings:
    +9
    Local Time:
    3:16 AM
    .webp images is created
    https://mojobus.org/wp-content/uploads/v2-bfw0t-jsqcp-e1716464553299.jpg.webp
    but not being served to visitors


    Code:
    # Centmin Mod Getting Started Guide
    # must read https://centminmod.com/getstarted.html
    # For HTTP/2 SSL Setup
    # read https://centminmod.com/letsencrypt-freessl.html
    
    # redirect from www to non-www  forced SSL
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    # server {
    #   server_name mojobus.org www.mojobus.org;
    #    return 302 https://$server_name$request_uri;
    # }
    
    server {
      listen 443 ssl http2;
     
      server_name mojobus.org www.mojobus.org;
    
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/ssl/mojobus.org/mojobus.org.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/mojobus.org/origin.crt;
      #ssl_verify_client on;
     
     
     
      # mozilla recommended
      ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
      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 Permissions-Policy "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()";
      #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/mojobus.org/log/access.log combined buffer=256k flush=5m;
      #access_log /home/nginx/domains/mojobus.org/log/access.json main_json buffer=256k flush=5m;
      error_log /home/nginx/domains/mojobus.org/log/error.log;
    
      include /usr/local/nginx/conf/autoprotect/mojobus.org/autoprotect-mojobus.org.conf;
      root /home/nginx/domains/mojobus.org/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/conf/wpincludes/mojobus.org/wpcacheenabler_mojobus.org.conf;
      #include /usr/local/nginx/conf/wpincludes/mojobus.org/wpsupercache_mojobus.org.conf;
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/wpincludes/mojobus.org/rediscache_mojobus.org.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_webp $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;
    
      }
    
    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/mojobus.org/htpasswd_wplogin;   
        include /usr/local/nginx/conf/php-wpsc.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-wpsc.conf;
        # https://jetpack.com/support/how-to-add-jetpack-ips-allowlist/
        include /usr/local/nginx/conf/jetpack_whitelist_ip.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-wpsc.conf;
        
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    location ~* /wp-admin/(load-styles\.php) {
        limit_req zone=xwprpc burst=5 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php-wpsc.conf;
        
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    #activpub
    location ^~ /.well-known/webfinger {
      auth_basic off;
      allow all;
      default_type text/plain;
      try_files $uri $uri/ /index.php?$args;
      break;
    }
    
    #well-know nostr
    
    location ^~ /.well-known/nostr.json {
         auth_basic off;
      allow all;
      default_type text/plain;
      try_files $uri $uri/ /index.php?$args;
      break;
    }
    
    
    #npub.pro support  Replace with the actual path to your Nostr-generated files
    #location ^~ /abgefahren/ {
    #    root /home/nginx/domains/mojobus.org/public/abgefahren;
    #    index index.html;
    #    try_files $uri index.html;
    #}
    
    
    # webp extension support if you are converting /uploads images to webp
     location ~ ^/wp-content/uploads/ {
       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;
      }
    }
    
    
    #Expires Header
    
    location ~* \.(jpg|jpeg|gif|png|webp)$ {
       expires 365d;
    }
    
    location ~* \.(pdf|css|html|js|swf)$ {
       expires 2d;
    }
    
    
      include /usr/local/nginx/conf/wpincludes/mojobus.org/wpsecure_mojobus.org.conf;
      include /usr/local/nginx/conf/php-wpsc.conf;
     
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/php-rediscache.conf;
      include /usr/local/nginx/conf/pre-staticfiles-local-mojobus.org.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;
    }
    
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,126
    12,179
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,739
    Local Time:
    1:16 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    did you recreate/copy over the /usr/local/nginx/conf/webp.conf include file and it it up in nginx.conf as per Nginx Serving WebP Images Conditionally Demo

    Code (Text):
    include /usr/local/nginx/conf/webp.conf;
    


    Code (Text):
    map $http_accept $webpok {
       default   0;
       "~*webp"  1;
    }
    
    map $http_cf_cache_status $iscf {
       default   1;
       ""        0;
    }
    
    map $webpok$iscf $webp_extension {
      11          "";
      10          ".webp";
      01          "";
      00          "";
    }
    
     
  5. Max

    Max Member

    124
    5
    18
    Feb 17, 2018
    Ratings:
    +9
    Local Time:
    3:16 AM
    Hello,
    Yes
    /usr/local/nginx/conf/webp.conf


    Code:
    map $http_accept $webpok {
       default   0;
       "~*webp"  1;
    }
    
    map $http_cf_cache_status $iscf {
       default   1;
       ""        0;
    }
    
    map $webpok$iscf $webp_extension {
      11          "";
      10          ".webp";
      01          "";
      00          "";
    }
    
    
    nginx.conf
    Code:
    # integration in vhosts created by addons/acmetool.sh
    more_set_headers "Server: nginx centminmod";
    more_set_headers "X-Powered-By: centminmod";
    #more_set_headers "Server: nginx";
    #more_clear_headers "X-Powered-By";
    
    # uncomment cloudflare.conf include if using cloudflare for
    # server and/or vhost site + setup cron job for command
    # /usr/local/src/centminmod/tools/csfcf.sh auto
    # run the auto command once to populate cloudflare ips
    #include /usr/local/nginx/conf/cloudflare.conf;
    # uncomment incapsula.conf include if using incapsula for
    # server and/or vhost site + setup cron job for command
    # /usr/local/src/centminmod/tools/csfincapsula.sh auto
    # run the auto command once to popular incapsula ips
    #include /usr/local/nginx/conf/incapsula.conf;
    include /usr/local/nginx/conf/maintenance.conf;
    #include /usr/local/nginx/conf/vts_http.conf;
    include /usr/local/nginx/conf/geoip.conf;
    include /usr/local/nginx/conf/webp.conf;
    include /usr/local/nginx/conf/ssl_include.conf;
    #include /usr/local/nginx/conf/pagespeedadmin.conf;
    include /usr/local/nginx/conf/fastcgi_param_https_map.conf;
    include /usr/local/nginx/conf/redisupstream.conf;
    include /usr/local/nginx/conf/wpcacheenabler_map.conf;
    include /usr/local/nginx/conf/normalize_encoding.conf;
    include /usr/local/nginx/conf/default_phpupstream.conf;