当前位置: 首页 > news >正文

nginx 配置 系统升级页面

默认80端口配置如下:

server {listen 80;  # 指定端口号server_name 192.168.2.96;  # 替换为实际域名或IP# 全局重定向到升级页面(排除自身防循环)if ($request_uri !~* "/upgrade.html") {return 307 /upgrade.html;  # 临时重定向状态码}# 升级页面配置location = /upgrade.html {root D:/soft/nginx/nginx-1.23.2/html;add_header Retry-After 3600;  # 建议重试时间(秒)}# 其他请求返回503(可选)location / {return 503;  # 服务不可用状态码}
}

html页面代码

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>系统升级维护中</title><style>body {font-family: 'Microsoft YaHei', sans-serif;background-color: #f5f5f5;color: #333;text-align: center;padding: 0;margin: 0;height: 100vh;display: flex;justify-content: center;align-items: center;}.maintenance-container {background: white;padding: 40px;border-radius: 8px;box-shadow: 0 2px 10px rgba(0,0,0,0.1);max-width: 600px;}h1 {color: #e74c3c;margin-bottom: 20px;}.icon {font-size: 60px;margin-bottom: 20px;color: #f39c12;}.progress-bar {height: 6px;background: #ecf0f1;border-radius: 3px;margin: 30px 0;overflow: hidden;}.progress {height: 100%;width: 60%;background: #3498db;animation: progress 2s ease-in-out infinite;}@keyframes progress {0% { width: 30%; }50% { width: 70%; }100% { width: 30%; }}.contact {margin-top: 30px;font-size: 14px;color: #7f8c8d;}</style>
</head>
<body><div class="maintenance-container"><div class="icon">🔧</div><h1>系统升级维护中</h1><p>我们正在对系统进行升级维护,以提供更好的服务体验。</p><p>预计完成时间:2025年06月20日 18:00</p><div class="progress-bar"><div class="progress"></div></div><p>升级期间将暂时无法访问,给您带来不便敬请谅解。</p><div class="contact"><p>如有紧急问题,请联系:support@example.com</p></div></div>
</body>
</html>

如果端口号不是默认80,目前实现方式

比如:监听9980,端口号不是80, 重定向页面请求地址不带有端口号,目前通过折中的方式解决, 监听80进行代理:

server {listen 80;server_name 192.168.2.96;location / {proxy_pass http://127.0.0.1:9980;  # 将请求转发到监听在9980端口的Nginx服务器proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;}
}
http://www.dtcms.com/a/255172.html

相关文章:

  • 深入理解XGBoost(何龙 著)学习笔记(五)
  • Vue框架深度解析:从Vue2到Vue3的技术演进与实践指南
  • Redis的大key和热key如何解决
  • 晨控CK-FR06与西门子PLC配置Modbus TCP通讯连接操作手册
  • React Native【详解】内置 API
  • 【攻防渗透】nps免杀
  • 【Datawhale组队学习202506】YOLO-Master task02 YOLO系列发展线
  • uniapp开发小程序,导出文件打开并保存,实现过程downloadFile下载,openDocument打开
  • 服务器手动安装并编译R环境库包:PROJ→RGDAL
  • JS入门——事件与事件绑定
  • Linux驱动第十章:SPI总线驱动子系统
  • 【unitrix】 3.5 类型级别的比较系统(cmp.rs)
  • RPC常见问题回答
  • 在 CI/CD 流程中使用 Jenkins 与 Docker 集成
  • 内存的代价:如何正确与 WASM 模块传值交互
  • 大内存对电脑性能有哪些提升
  • Redis ⑩-持久化 || RDB
  • 算法-每日一题(DAY11)每日温度
  • 【VUE】某时间某空间占用情况效果展示,vue2+element ui实现。场景:会议室占用、教室占用等。
  • MySQL基础多表查询
  • uniapp实现像qq消息列表左滑显示右侧操作栏效果
  • Qt—(Qt线程,Qt进程,,QT与sqlite数据库)
  • 学习华为 ensp 的学习心得体会
  • SP-VLA:一种用于 VLA 模型加速的联合模型调度和 token 剪枝方法
  • 力扣-136.只出现一次的数字
  • C语言:二分搜索函数
  • linux中的数据检索
  • mysql查询使用`_rowid` 虚拟列
  • iOS APP上架App Store实践:通过自动化流程和辅助工具高效提
  • 【Python】.pyz:源码与依赖打包