Nginx 自定义404、500、502 页面 您所在的位置:网站首页 html错误代码502 Nginx 自定义404、500、502 页面

Nginx 自定义404、500、502 页面

2024-07-13 02:24| 来源: 网络整理| 查看: 265

利用nginx的反向代理来实现 服务器404 和500 等状态码的自定义页面

1.nginx配置文件 nginx.conf 配置开启代理错误拦截 和配置页面  下划线部分 

http { ...... proxy_intercept_errors on; fastcgi_intercept_errors on; server { ...... error_page 404 /notfind.html; error_page 500 /error.html; error_page 502 503 504 /error502.html; } }

2.编写自定义页面,将页面放置在nginx路径下的html 文件夹下 页面中用到的图片什么的都放置与此文件夹下

3.重启nginx 配置生效 OK

404页面代码

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 404-对不起!您访问的页面不存在 .head404{ width:580px; height:234px; margin:50px auto 0 auto; background:url(http://zhaixt.info/head404.png) no-repeat; } .txtbg404{ width:499px; height:169px; margin:10px auto 0 auto; background:url(http://zhaixt.info/txtbg404.png) no-repeat;} .txtbg404 .txtbox{ width:390px; position:relative; top:30px; left:60px;color:#eee; font-size:13px;} .txtbg404 .txtbox p {margin:5px 0; line-height:18px;} .txtbg404 .txtbox .paddingbox { padding-top:15px;} .txtbg404 .txtbox p a { color:#eee; text-decoration:none;} .txtbg404 .txtbox p a:hover { color:#FC9D1D; text-decoration:underline;} 对不起,您请求的页面不存在、或已被删除、或暂时不可用 请点击以下链接继续浏览网页 》返回上一页面 》 文字识别 》 图表转换

500页面代码

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> We're sorry, but something went wrong (500) .head500{ width:580px; height:234px; margin:50px auto 0 auto; background:url(http://zhaixt.info/head500.png) no-repeat; } .txtbg500{ width:499px; height:169px; margin:10px auto 0 auto; background:url(http://zhaixt.info/txtbg404.png) no-repeat;} .txtbg500 .txtbox{ width:390px; position:relative; top:30px; left:60px;color:#eee; font-size:13px;} .txtbg500 .txtbox p {margin:5px 0; line-height:18px;} .txtbg500 .txtbox .paddingbox { padding-top:15px;} .txtbg500 .txtbox p a { color:#eee; text-decoration:none;} .txtbg500 .txtbox p a:hover { color:#FC9D1D; text-decoration:underline;} 请点击以下链接继续浏览网页 》返回上一页面 》 文字识别 》 图表转换

502页面代码

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> We're sorry, but something went wrong (502) .head500{ width:580px; height:234px; margin:50px auto 0 auto; background:url(http://zhaixt.info/502.png) no-repeat; } .txtbg500{ width:499px; height:169px; margin:10px auto 0 auto; background:url(http://zhaixt.info/txtbg404.png) no-repeat;} .txtbg500 .txtbox{ width:390px; position:relative; top:30px; left:60px;color:#eee; font-size:13px;} .txtbg500 .txtbox p {margin:5px 0; line-height:18px;} .txtbg500 .txtbox .paddingbox { padding-top:15px;} .txtbg500 .txtbox h1,h2{ color:#FC9D1D;} SORRY 服务升级中...如等待时间过长,请联系宅小涛

 

欢迎大家参考 !

 

 

 

 

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有