Nginx優雅顯示錯誤頁面
阿新 • • 發佈:2020-09-11
#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;
}
}
}