- 维护页面内容
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>系统正在维护当中</title>
<style>
body {
box-sizing: border-box;
}
.content {
position: absolute;
top: 35%;
left: 50%;
transform: translate(-50%, -50%);
}
.content .view_pic {
width: 400px;
}
.content .text {
text-align: center;
font-weight: 700;
color: rgb(118, 121, 128);
font-size: 20px;
}
</style>
</head>
<body>
<div class="content">
<img class="view_pic" src="./images/weihu.png" alt="图片加载失败">
<div class="text">系统正在维护中</div>
</div>
</body>
</html>
- nginx配置
server {
listen 8888;
server_name localhost;
client_max_body_size 100m;
location / {
root /usr/local/404_page;
index defend.html;
}
set $flag 0;
#标记图片请求,使不被rewrite
if ($request_uri ~ ^/images/.*png) {
set $flag "${flag}2";
}
#标记只要uri不是defend.html结尾的请求
if ($request_uri !~ "^/defend.html$") {
set $flag "${flag}1";
}
#标记为0或1的都重定向
if ($flag = "01") {
rewrite ^(.*) http://180.101.234.30:18092/defend.html permanent;
}
#if ($request_uri !~ "^/defend.html$") {
# rewrite ^(.*) http://180.101.234.30:18092/defend.html permanent;
#}
location /platform/ {
alias /usr/local/service-platform/dist/;
try_files $uri $uri/ @router;
index index.html;
}
location /zb-admin {
if ( !-e $request_filename ){
proxy_pass http://service-platform;
}
}
location /enterprise/ {
alias /usr/local/service-platform-enterprise/dist/;
try_files $uri $uri/ @router;
index index.html;
}
由于html请求中带有一个图片请求,跳转时如果不把图片请求通过if ($request_uri ~ ^/images/.*png)匹配出就会无法加载