Join the community today
Register Now

Wordpress Installing WebP Express Wordpress Plugin on Centmin Mod Nginx

Discussion in 'Blogs & CMS usage' started by eva2000, May 11, 2019.

  1. Shirkit

    Shirkit New Member

    12
    1
    3
    Feb 6, 2019
    Ratings:
    +4
    Local Time:
    7:49 PM
    No I literally mean there's a new 'Tests' module inside the plugin configuration: https://imgur.com/tzmWlEy


    I know I only need one of the libraries to work, but the tests are failing.
     
  2. eva2000

    eva2000 Administrator Staff Member

    49,034
    11,232
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,483
    Local Time:
    8:49 AM
    Nginx 1.21.x
    MariaDB 10.x
    You mean those 3x redirection rule tests ? They won't work they test .htaccess apache file. Nginx doesn't support Apache's .htaccess.
     
  3. zkylizer

    zkylizer New Member

    16
    0
    1
    Jun 5, 2019
    Ratings:
    +2
    Local Time:
    5:49 AM
    1.17.0
    MariaDB 10
    if using webp express still need image optimize plugin or not ?
    because in webp expresss already has feature reduce image quality
     
  4. eva2000

    eva2000 Administrator Staff Member

    49,034
    11,232
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,483
    Local Time:
    8:49 AM
    Nginx 1.21.x
    MariaDB 10.x
    yeah you can just use webp express plugin
     
  5. zkylizer

    zkylizer New Member

    16
    0
    1
    Jun 5, 2019
    Ratings:
    +2
    Local Time:
    5:49 AM
    1.17.0
    MariaDB 10
    1. are safe removing original .jpg or .png after converted to .webp ?

    2. and how i can fix multiple vary ?
    vary Accept-Encoding ( how to remove this default vary )
    vary Accept

    3. if i using add_header X-Content-Type-Options "nosniff" from server { will apply to all type file css, js, html, etc? or i still need uncomment in /usr/local/nginx/conf/staticfiles-hsts.conf
     
    Last edited: Apr 19, 2020
  6. eva2000

    eva2000 Administrator Staff Member

    49,034
    11,232
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,483
    Local Time:
    8:49 AM
    Nginx 1.21.x
    MariaDB 10.x
    no you need original image + webp always as not all browsers support webP so if you remove original image, non-webP supported browsers will have broken images

    webP saves image size for clients whose browser supports webP. webP does not save disk space usage for the web site, it increases it as it has to store both original image + webP image which will increase disk usage.

    those are normal Accept and Accept-Encoding are different not the same
    You have to tread what nosniff does and decide for yourself if it's suited to your own web site Security Headers - X-Content-Type: nosniff | Sucuri Docs and you can check which requests get nosniff header by inspecting it in web browser dev tools network tab for header responses or via curl i.e.
    Code (Text):
    curl -I https://yourdomain.com/path/to/image/or/css/jss

    example
    Code (Text):
    curl -I https://www.cloudflare.com
    HTTP/2 200
    date: Sun, 19 Apr 2020 09:21:34 GMT
    content-type: text/html; charset=utf-8
    set-cookie: __cfduid=dedfdfd2735c84edf7a9403822b7880b01587288094; expires=Tue, 19-May-20 09:21:34 GMT; path=/; domain=.www.cloudflare.com; HttpOnly; SameSite=Lax; Secure
    cf-ray: 58658e5d4d508552-ORD
    age: 51
    cache-control: public, s-max-age=30
    strict-transport-security: max-age=31536000
    vary: Accept-Encoding
    cf-cache-status: HIT
    expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
    x-content-type-options: nosniff
    x-frame-options: SAMEORIGIN
    x-xss-protection: 1; mode=block
    server: cloudflare
    alt-svc: h3-27=":443"; ma=86400, h3-25=":443"; ma=86400, h3-24=":443"; ma=86400, h3-23=":443"; ma=86400
    cf-request-id: 0233574e4f00008552bb37e200000001
    

    the add_header will apply to whichever context the line is added to within a location{], server{} or specific file extension match location{} context. So answer is it depends on where you use add_header directive as to where it is applied
     
  7. skringjer

    skringjer NoobMaster69

    191
    23
    18
    Apr 21, 2019
    Ratings:
    +39
    Local Time:
    3:49 AM
    Nginx 1.21.6
    MariaDB 10.3.x
    Okay so i followed the guide and everything is working properly. Screenshot

    I wanted to ask why is the original image loaded in JPG or PNG

    Sorry i still haven't properly studied this, i know we need original files for unsupported browsers.

    But in supported browsers it loads all the images originally when i inspect element.
     
  8. eva2000

    eva2000 Administrator Staff Member

    49,034
    11,232
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,483
    Local Time:
    8:49 AM
    Nginx 1.21.x
    MariaDB 10.x
    that is normal - image extension is .jpg or .png but mime time is webP when converted
     
  9. ct_roy

    ct_roy Premium Member Premium Member

    39
    6
    8
    Jun 21, 2020
    Ratings:
    +11
    Local Time:
    11:49 PM
    1.17.10
    10.3.22
    @eva2000
    WebP express is functioning great for me overall with your config as per page 1 of this thread.
    Just wondering if anything can be done about the various errors/warnings that crop up in the plugins live tests.

    None of these actually stop me using the plugin as the bulk convertor catches anything historic (and works fine with your whitelist exception). and the convert on upload catches anything new.

    But I'm guessing some might get missed with updates to theme images (and forgetting to re-run a bulk conversion) so it would be nice to have the plugins fallbacks work.

    I'm guessing some additional whitelist rules would be needed for the on demand and realizor scripts per their recommended nginx config (as per below).

    Any thoughts on this?


    Code:
    # WebP Express rules
    # --------------------
    location ~* ^/?wp-content/.*\.(png|jpe?g)$ {
      add_header Vary Accept;
      expires 365d;
      if ($http_accept !~* "webp"){
        break;
      }
      try_files
        /wp-content/webp-express/webp-images/doc-root/$uri.webp
        $uri.webp
        /wp-content/plugins/webp-express/wod/webp-on-demand.php?xsource=x$request_filename&wp-content=wp-content
        ;
    }
    
    # Route requests for non-existing webps to the converter
    location ~* ^/?wp-content/.*\.(png|jpe?g)\.webp$ {
        try_files
          $uri
          /wp-content/plugins/webp-express/wod/webp-realizer.php?xdestination=x$request_filename&wp-content=wp-content
          ;
    }
    # ------------------- (WebP Express rules ends here)

    e.g.

    [​IMG]

    [​IMG]

    Redirection error
    [​IMG]

    Realizer error
    [​IMG]
     
  10. Shirkit

    Shirkit New Member

    12
    1
    3
    Feb 6, 2019
    Ratings:
    +4
    Local Time:
    7:49 PM
    On my end the tests always end up failing, despite the plugin working correctly. Try checking if it's working despite the tests.
     
  11. Tinkerd10

    Tinkerd10 New Member

    27
    3
    3
    Sep 28, 2016
    Ratings:
    +15
    Local Time:
    11:49 PM
    1.11
    5.5
    Hi

    In this version i'm currently using it has more options, in particularly
    You need to change Destination structure to: image root.
    Otherwise it won't work, as you mentioned both images need to be on the same folder.

    Destination structure:
    This setting determines how the converted files are structured within the folder that WebP Express uses for storing webp images (from here on called "the cache root")

    "document root"
    When "document root" is selected, the webp images will be stored in:
    [cache root]/doc-root/[relative path of source image, from document root].

    "image roots"
    A Wordpress site has images stored in different locations. Uploaded files are for example stored in the uploads folder, which is usually - but not always - located in the "wp-content" folder. I call the uploads folder an "image root". Other roots are: "themes", "plugins", "wp-content" and "index". When the "image roots" setting is selected, the webp files are stored in a structure that mirrors the relative path of the source image within its image root. For "uploads", that location is:
    [cache root]/uploads/[relative path of source image, from uploads root].
    More generally we have:
    [cache root]/[image root]/[relative path of source image, from its image root].

    Which option is best?
    Well, in most cases it does not matter. However, there are hosts out there that have set the document root up incorrectly, so I would generally recommend "Image roots". On Nginx, I however recommend "Document root", as it requires fewer rewrite rules.​
     
  12. eva2000

    eva2000 Administrator Staff Member

    49,034
    11,232
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,483
    Local Time:
    8:49 AM
    Nginx 1.21.x
    MariaDB 10.x