通过Nginx实现系统更新中温馨提示页面

Nginx反向代理,负载均衡,简单好用,应用在目前大部分的系统部署架构中。

有经验的实施人员都会发现,在系统更新时,前端访问会报错,用户体验极其不好,会引起咨询或引发投诉。

那么通过Nginx一个简单的配置,加一个html页面,即可解决上述烦恼。

如下:

1、编写一个简单的html页面,命名为:upgrading.html

PC端效果如下

 移动端效果如下

 有需要的html页面代码的同学

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>系统更新维护中</title>
</head>
<style>
*{
 margin:0;
 padding:0;
 }
html{
 height:50%;
 }
body{
 background:#F1FDFE;
 height:100%;
 }
.mom{
 width:600px;
 height:300px;
 line-height:100px;
 text-align:center;
 font-size:30px;
 border-width:5px;
 border-style:dashed;
 border-color:#FFFFFF;
 background:#e6fafd;
 color:rgb(255, 0, 55);
 }
</style>
<body>
<div>
<div class="web_notice" style="position: fixed;top: 0;left: 0;width: 200%;height: 100%;background: rgba(0,0,0,0.3);z-index: 99999;">
<div style="position: fixed;top: 50%;left: 50%;width: 600px;background: #FFF;transform: translate(-50%, -50%);border-radius: 40px;padding: 100px 25px;" class="mom">
<h1 style="font-weight: bold;top: 50%;text-align: center;font-size: 45px;margin-top: -40px;">系统更新维护中</h1><div style="font-size:33px;margin-top:30px;line-height:50px;color:#000000;text-align:left">&nbsp;&nbsp;&nbsp;&nbsp;尊敬的用户,您好!系统于11月25日00:00~24:00进行紧急维护,届时访问会受到影响,给您造成不便敬请谅解。</div>
<a style="display: block;background: #98a3ff;color: #FFF;text-align: center;font-weight: bold;font-size: 25px;line-height: 60px;margin: 0 auto;margin-top: 60px;border-radius: 32px;width: 80%;" onclick="javascript:document.querySelector('.web_notice').remove()">我知道了</ a>
</div>
</div>
</div>
</body>
</html>

2、将html页面上传至Nginx的html目录下,如:/opt/nginx/html 路径下

3、在代理服务器中,调整Nginx配置

在server 配置中 增加以下 红色部分

server {
        listen       8080;
        server_name  19.xx.xx.89;

        client_max_body_size 2000m; 
        client_body_buffer_size 5m; 

        #更新公告begin
        location ~* {
               try_files ''  /upgrading.html;
        }
        location = /upgrading.html {
                     root   /opt/nginx/html;
                     index upgrading.html;
        }
        #更新公告end

.....

}

保存

4、执行命令:nginx -s reload

重启Nginx,看看效果。

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值