修改主配置文件

server {
listen 80;
server_name http.com;
location / {
root /http;
index index.html;
}
error_page 404 /404.html;
location = /404.html {
root /http;
}
}
systemctl restart nginx

创建错误反馈页面

echo "404 not found" > /http/404.html

访问不存在的页面

elinks http.com/1111

Nginx基础篇(9)自定义404页面_nginx