Все, разобрался, получилось так
        location / {
                location ~ [^/]\.ph(p\d*|tml)$ {
                        try_files /does_not_exists @apacheback;
                }
                location ~*
^.+\.(gif|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf|woff|woff2|ico|ttf|eot|otf|flv)$
{
                        try_files $uri $uri/ @fallback;
                        expires 365d;
                }
                location ~* ^.+\.(jpg|jpeg|png)$ {
                        set $ax 0;
                        if ( $http_accept ~* "webp" ) {
                            set $ax 1;
                        }
                        if ( -e $root_path/webp$uri ){
                            set $ax "${ax}1";
                        }
                        if ($http_cookie ~* "modx_admin" ) {
                            set $ax 0;
                        }
                        if ( $ax = "11" ) {
                            rewrite ^ /webp$uri last;
                            return  403;
                        }
                        expires 365d;
                        try_files $uri $uri/ @fallback;
                }
                location ^~ /webp/ {
                        types { } default_type "image/webp";
                        add_header Vary Accept;
                        expires 365d;
                        try_files $uri $uri/ @fallback;
                }
                location / {
                        try_files /does_not_exists @fallback;
                }
        }

Posted at Nginx Forum: 
https://forum.nginx.org/read.php?21,286117,286144#msg-286144

_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru

Ответить