А как здесь location /webp прикрутить? подскажите.
Вот полный конфиг хоста

server {
        server_name mysite www.mysite;
        charset UTF-8;
        index index.php index.html;
        disable_symlinks if_not_owner from=$root_path;
        include /etc/nginx/vhosts-includes/*.conf;
        include /etc/nginx/vhosts-resources/mysite/*.conf;
        access_log /var/www/httpd-logs/mysite.access.log;
        error_log /var/www/httpd-logs/mysite.error.log notice;
        set $root_path /var/www/www-root/data/www/mysite;
        root $root_path;
        location / {
                location ~ [^/]\.ph(p\d*|tml)$ {
                        try_files /does_not_exists @fallback;
                }
                location ~*
^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf|woff|woff2|ico|ttf)$
{
                        try_files $uri $uri/ @fallback;
                }
                location / {
                        try_files /does_not_exists @fallback;
                }
        }
        location @fallback {
                proxy_pass http://127.0.0.1:8080;
                proxy_redirect http://127.0.0.1:8080 /;
                proxy_set_header Host $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Forwarded-Port $server_port;
                access_log off;
        }
        return 301 https://$host:443$request_uri;
        gzip on;
        gzip_comp_level 9;
        gzip_disable "msie6";
        gzip_types text/plain text/css application/json application/x-javascript
text/xml application/xml application/xml+rss text/javascript
application/javascript;
        listen 55.55.55.55:80;
}
server {
        server_name mysite www.mysite;
        ssl_certificate "/var/www/httpd-cert/www-root/mysite_le3.crtca";
        ssl_certificate_key "/var/www/httpd-cert/www-root/mysite_le3.key";
        ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
        ssl_prefer_server_ciphers on;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
        charset UTF-8;
        index index.php index.html;
        disable_symlinks if_not_owner from=$root_path;
        include /etc/nginx/vhosts-includes/*.conf;
        include /etc/nginx/vhosts-resources/mysite/*.conf;
        access_log /var/www/httpd-logs/mysite.access.log;
        error_log /var/www/httpd-logs/mysite.error.log notice;
        set $root_path /var/www/www-root/data/www/mysite;
        root $root_path;


        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 break;
                            add_header Vary Accept;
                            add_header Content-Type image/webp;
                        }

                        #types { } default_type "image/webp";
                        
                        expires 365d;
                        try_files $uri $uri/ @fallback;
                }
                location / {
                        try_files /does_not_exists @fallback;
                }
        }
        location @fallback {
                proxy_pass http://127.0.0.1:6081;
                proxy_redirect http://127.0.0.1:6081 /;
                proxy_set_header Host $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Forwarded-Port $server_port;
                access_log off;
        }
        location @apacheback {
                proxy_pass http://127.0.0.1:8080;
                proxy_redirect http://127.0.0.1:8080 /;
                proxy_set_header Host $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Forwarded-Port $server_port;
                access_log off;
        }
        gzip on;
        gzip_comp_level 9;
        gzip_disable "msie6";
        gzip_types text/plain text/css application/json application/x-javascript
text/xml application/xml application/xml+rss text/javascript
application/javascript;
        listen 55.55.55.55:443 ssl http2;
}

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

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

Ответить