VPS侦探论坛

标题: 怎么让部分页面不显示自定义维护页面? [打印本页]

作者: puffbaby    时间: 2019-3-14 11:30
标题: 怎么让部分页面不显示自定义维护页面?
在网站的根目录上传了一个自定义的503页面文件夹,包含html,css,和图片。然后希望部分页面正常显示,其余页面都显示这个503维护页面。我的nginx部分配置:
  1. location / {
  2. # 跨域设置
  3. add_header 'Access-Control-Allow-Origin' $http_origin;
  4. add_header 'Access-Control-Allow-Credentials' 'true';
  5. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  6. add_header 'Access-Control-Allow-Headers' 'DNT,Accept,Origin,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  7. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
  8. if ($request_method = 'OPTIONS') {
  9.             add_header 'Access-Control-Max-Age' 1728000;
  10.             add_header 'Content-Type' 'text/plain; charset=utf-8';
  11.             add_header 'Content-Length' 0;
  12.             return 204;
  13. }

  14. # 维护页面

  15. set $flag 0;
  16. if ($request_uri !~ "(/houtai/).*$"){
  17.       set $flag "${flag}1";
  18. }
  19. if ($request_uri !~ "/503/503.html$" ){
  20.       set $flag "${flag}2";
  21. }
  22. if ($request_uri !~ "(/503/css/.*)$" ){
  23.       set $flag "${flag}3";
  24. }
  25. if ($request_uri !~ "(/503/images/.*)$" ){
  26.       set $flag "${flag}4";
  27. }

  28. if (-f $document_root/503/503.html) {
  29.       set $flag "${flag}5";
  30. }

  31. if ($request_uri !~ "(/zt/).*$"){
  32.       set $flag "${flag}6";
  33. }

  34. if ($flag = "0123456") {
  35.            return 503;
  36.          }

  37. }

  38. error_page 503 @maintenance;
  39.     location @maintenance {
  40.     rewrite ^(.*)$ /503/503.html break;
  41. }
复制代码


希望访问的URL包含houtai,zt和503的时候显示正常,然后其他的访问码是503。
实际发现,部分URL应该是显示维护页面但是却是正常显示了,请问大佬,我这里应该怎么弄?
作者: licess    时间: 2019-3-14 13:26
可能匹配规则上有问题
作者: puffbaby    时间: 2019-3-14 13:29
标题: 回复 2# 的帖子
军哥 你看规则应该怎么弄呢 排除 houta 503  zt 这三个目录
作者: 01rfb    时间: 2019-5-26 15:33
看看,学习一下




欢迎光临 VPS侦探论坛 (https://bbs.lnmp.com/) Powered by Discuz! X3.4