编程技术分享平台

网站首页 > 技术教程 正文

nginx配置维护页面(nginx界面配置管理)

xnh888 2024-10-15 18:22:54 技术教程 15 ℃ 0 评论

经常性的,系统维护,我们需要配置一个维护页面,以便让用户看到。而同时自己还需要能访问。

也就是说在维护的同时,还需要指定的IP能访问。

以下就是一个nginx配置维护页面的例子:

其中:

/weihu/是维护页面的URL,应该在/data/www下建一个weihu的目录,把维护页面index.html放到这个目录内.

103.214.84.224|101.231.194.4|180.168.251.235为允许访问的IP地址。

最终效果:当用户访问真实的URL时,会显示跳转至/weihu/

详细配置如下:

 location /weihu/ {
 root /data/www/;
 index index.html weihu.html logo.png upgrade.png;
 access_log /data/log/nginx/tx.log ha;
 }
 set $weihu 1;
 if ($http_x_forwarded_for ~* "103\.214\.84\.224|101\.231\.194\.4|180\.168\.251\.235") {
 set $weihu 0;
 }
 if ($document_uri ~* "/weihu") {
 set $weihu 0;
 }
 if ($weihu = "1") {
 rewrite .* /weihu/ redirect;
 }

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表