Welcome! Log In Create A New Profile

Advanced

rewrite in custom 404 location

Артём Томюк
June 27, 2017 06:42AM
is it possible to create "if" rule with rewrite action inside custom 404
location?
the task is fallback to jpg if upstream returns 404 for .webp request.
i've double-checked regexp's - they seems to be write....



location ~* \.(jpg|mp4|svg|jpeg|gif|png|css|bmp|js|swf|webp|jp2|ico)$ {

etag on;

proxy_cache site;

proxy_cache_valid 404 302 1m;

expires max;

proxy_cache_valid 2h;

proxy_pass http://cdn;

proxy_intercept_errors on;

proxy_connect_timeout 5s;

proxy_next_upstream error timeout http_404 http_403 http_500
http_502 http_503 http_504;

error_page 404 /webp.html;

}


location = /webp.html {

if ($request_filename ~* ^.+.webp$) {

rewrite ^/(.*)\.webp$ /$1.jpg redirect;

}

root /var/www/;

}
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

rewrite in custom 404 location

Артём Томюк June 27, 2017 06:42AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 305
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready