nginx优化-错误页面的优雅显示error_page

错误页面的优雅显示error_page 阿里门户网站天猫的nginx优雅显示配置案例


在虚拟主机配置文件中配置 #错误页面优化显示 注意将下面两个图片上传至服务器中
error_page 500 501 502 503 504 http://www.abc.com/error2.jpg;
error_page 400 403 404 405 408 410 412 413 414 415 http://www.abc.com/error1.jpg;


[root@web01 ~]# cat /application/nginx/conf/extra/www.conf server { listen80; server_name www.abc.com; rewrite ^(.*)$https://$host$1 permanent; } server { listen443; server_namewww.abc.com; roothtml/www; indexindex.php index.html index.htm; #https证书 ssl on; ssl_certificate /application/nginx/conf/key/server.crt; ssl_certificate_key /application/nginx/conf/key/server.key; #访问日志 access_loglogs/access_www.logmain; #隐藏版本号 server_tokens on; ##防盗链 #location ~* .*\.(jpg|gif|swf|flv|wma|wmv|asf|mp3|mmf|zip|rar)$ {#小括号中不能包含要跳转的图片结尾格式.png,-->否则会进入死循环跳转 #valid_referers none blocked *.abc.com abc.com www.abc.com; #if ($invalid_referer) { ##return 403; #rewrite ^/https://www.abc.com/fangdaolian.png; #} #} #客户端对静态内容缓存 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30y; root html/www; } location ~ .*\.(js|css)?$ { expires 30d; root html/www; } #php解析 location ~ .*\.(php|php5)?$ { root html/www; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; #FastCGI 相关参数调优 #fastcgi_cache ngx_fcgi_cache; fastcgi_cache_valid 200 302 1h; fastcgi_cache_valid 301 1d; fastcgi_cache_valid any 1m; fastcgi_cache_min_uses 1; fastcgi_cache_use_stale error timeout invalid_header http_500; fastcgi_cache_key http://$host$request_uri; } #错误页面优化显示 注意将下面两个图片上传至服务器中 error_page 500 501 502 503 504 http://www.abc.com/error2.jpg; error_page 400 403 404 405 408 410 412 413 414 415 http://www.abc.com/error1.jpg; }

【nginx优化-错误页面的优雅显示error_page】转载于:https://blog.51cto.com/13673885/2300278

    推荐阅读