Nginx优雅显示错误页面
#error_page配置的是http这种的网络地址
[root@web01 conf.d]# cat error.conf
server {
listen 80;
server_name linux.error.com;
location / {
root /code/error;
index index.html;
error_page 404 http://www.baidu.com;
}
}
[root@web01 /code/error]# vim /etc/nginx/conf.d/error.conf
server {
listen 80;
server_name linux.error.com;
location / {
root /code/error;
index index.html;
error_page 404 403 /404.jpg;
}
}
[root@web01 /code/error]# vim /etc/nginx/conf.d/error.conf
server {
listen 80;
server_name linux.error.com;
root /code/error;
index index.php;
error_page 404 403 /404.html;
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
if (!-e $request_filename) {
rewrite (.*) http://linux.error.com/404.jpg;
}
}
}
本文来自博客园,作者:六月OvO,转载请注明原文链接:https://www.cnblogs.com/chenlifan/p/13652263.html