网站首页 > 知识剖析 正文
你们是不是会遇到这样的需求,某个新版本上线时,需要停机(这里不考虑灰度发布),如果不设置维护页面,用户访问时就会很不友好,显示404或者显示503;我们就希望在维护的时间段内,用户访问域名时显示系统正在维护中,你们都是怎么实现的呢?
这里我分享下在nginx如何配置实现:
1、首页新增一个conf文件,放在某个路径下,如:/etc/tmp/page.conf
2、要维护的域名下 include 该配置文件
3、对应满足条件的请求用户,rewrite到指定页面
具体配置如下:
1)、
location / {
#这里你要做的条件判断,放在配置文件里,需要时去掉注释#
# include /etc/tmp/page.conf;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header remote-port $remote_port;
proxy_pass http://gateway_servers/;
}
2.1)、这个写在/etc/tmp/page.conf里
location / {
root /data/page/; #你要展示的页面放在这个路径下
index index.html;
}
2.2)、
if ( $update_flag != 1 ) # 这里具体可以参考上一篇文章
{
return 302 https://xxx.xxx.com/page/index.html;
}
4)、index.thml
自己写个简单页面,注明维护时间
这个方法在配置上稍等有点复杂,但还是很实用的,你们一般是怎么做的呢?
猜你喜欢
- 2025-03-06 别看它又小又少,黄豆大小,人体只有4颗,如果出了问题,就会...
- 2025-03-06 #天真不能无鞋#记个流水账的鞋:二十余双鞋子简评
- 2025-03-06 javascript实现获取中文汉字拼音首字母
- 2025-03-06 少年三国志零兑换码大全 少年三国志2礼包兑换码怎么用
- 2025-03-06 第32批免征车辆购置税新能源汽车车型目录公布
- 2025-03-06 肾病化验指标不会看?直接图表讲解告诉你,简单易懂!快收藏
- 2025-03-06 蠕动泵TH10泵头流量参数
- 2025-03-06 pdfkit | 利用python实现html文件转pdf
- 2025-03-06 《逆水寒》:全面攻略详细解析
- 2025-03-06 PDF编辑与THML编辑器支持pdf转html、html转pdf、pdf转图片
- 最近发表
- 标签列表
-
- xml (46)
- css animation (57)
- array_slice (60)
- htmlspecialchars (54)
- position: absolute (54)
- datediff函数 (47)
- array_pop (49)
- jsmap (52)
- toggleclass (43)
- console.time (63)
- .sql (41)
- ahref (40)
- js json.parse (59)
- html复选框 (60)
- css 透明 (44)
- css 颜色 (47)
- php replace (41)
- css nth-child (48)
- min-height (40)
- xml schema (44)
- css 最后一个元素 (46)
- location.origin (44)
- table border (49)
- html tr (40)
- video controls (49)