• Resolved knipers

    (@knipers)


    I have install e save settings for webp express.

    I have generate all images with bulk convert.

    For example:
    https://www.viveremcasa.com/wp-content/uploads/2018/09/decoracao_com_sofa_azul_em_l.jpg.webp

    I edit /etc/nginx/nginx.conf and add:

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    # Webp
    map $http_accept $webp_suffix {
    default “”;
    “~*webp” “.webp”;
    }

    my file /etc/nginx/mime.type contains:
    image/webp webp;

    On file /etc/nginx/sites-available/website.com.conf my server is https and i add:
    location ~* ^/images/.+\.(png|jpg)$ {
    add_header Vary Accept;
    try_files $uri$webp_suffix $uri =404;
    }

    i restarted nginx.service

    web site is work but not webp images.

    images are still displayed in jpg or png.

    Did i do something wrong? forgot something? please help me…

    thanks

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author rosell.dk

    (@roselldk)

    location ~* ^/images/.+\.(png|jpg)$ { looks wrong – your images are not in a folder named “images”. Also, you might want to redirect jpegs with the “jpeg” extension (not just those with “jpg” extension).

    I suggest this line instead.

    location ~* ^/?wp-content/.*\.(png|jpe?g)$ {

    If you haven’t already, please check out the I am on Nginx / OpenResty section in the FAQ

    Thread Starter knipers

    (@knipers)

    @roselldk thanks for help,

    I try change location with your instructions, but no work.

    I read all openresty, I try all steps, but no work.

    Do you have any other suggestions to solve?

    My Configs:
    https://ibb.co/G25LyqG
    https://ibb.co/fdm617Q
    https://ibb.co/64GNNtQ

    • This reply was modified 5 years, 7 months ago by knipers.
    Plugin Author rosell.dk

    (@roselldk)

    The try_files you are using are looking for webp’s in the same folder as the originals, but you have configured WebP Express to store them in a separate folder.
    You can change the setting. But either way, you should add a line in the try_files which looks for webps in the separate folder, because the setting only applies to the images in the “upload” folder. For other images, the webps are stored in a separate folder.

    You should add this line:

    
    /wp-content/webp-express/webp-images/doc-root/$uri.webp
    

    The following will look for existing webps in both places:

    
    location ~* ^/?wp-content/.*\.(png|jpe?g)$ {
      add_header Vary Accept;
      if ($http_accept !~* "webp"){
        break;
      }
      try_files
        /wp-content/webp-express/webp-images/doc-root/$uri.webp
        $uri.webp
        ;
    }
    

    I btw see that you have put the *map* in the http context. Perhaps it needs to be in the server context? Anyway, the solution above does not rely on the mapping.

    Thread Starter knipers

    (@knipers)

    @roselldk thanks for help, I was using “operation mode” as “varied images responses” on nginx, this operation mode does not work with nginx (I tried all possible configurations today all day long and believe none worked).

    But I managed to solve by doing the following configuration:
    – Operation mode: CDN Friendly
    – Images types to convert: Both jpegs and pngs
    – Destination Folder: Mingled
    – File Extension: Append “.webp”
    – Alter HTML (Checked) with default options

    If possible, I suggest adding a new mode of operation named “Nginx” that sets these options by default and hides htaccess options and alerts.

    This would help other users not to spend time with settings that will not work for nginx.

    Plugin Author rosell.dk

    (@roselldk)

    Good to hear that you made it work!
    I btw updated the Nginx FAQ section to make it more readable.

    Regarding better Nginx UI, I actually already have it on the roadmap ?? I do not plan to create a new operation mode, but I plan to make the UI reflect that it is Nginx. And I will add generation of nginx rules that matches the setup and settings (for display, ie when saving or clicking a “show nginx rules” button)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Webp Express not working on nginx’ is closed to new replies.