<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## 簡介 高級規則是最具靈活性的規則配置,需要使用者有較好的動手能力,特別復雜的功能和配置,都可以在高級規則中實現(防重放檢查,驗證動態驗證碼,簽名驗簽檢查等等等等...) ## 入口 ![](https://img.kancloud.cn/2f/27/2f277ea955858c2977039a288f235e5b_686x637.png) ## 界面介紹 先看一下高級規則主界面,這里可以看到所有已經配置的高級規則所有信息 ![](https://img.kancloud.cn/bb/e1/bbe1f654a86f45a4f40f3c63d722a9c7_991x1325.png) 凡是出現上移、下移...配置規則優先級的規則組,共性都是一樣的,規則的順序修改后,一定要 **應用** ,然后在 **保存** * 高級匹配規則開關:配置高級規則總開關的 * 上移:移動該條規則順序 優先 * 下移:移動該條規則順序 落后 * 置頂:調整該條規則優先級 最高 * 置底:調整該條規則優先級 最低 【注:跳轉規則順序(上移/下移/置頂/置底)后需要應用優先級才可以生效】 ## 添加規則 先看一下添加規則的界面吧 ![](https://img.kancloud.cn/87/d7/87d7b230f1f62d69da78e1d26761eaef_744x524.png) * des:對該條規則的人為描述,方便規則的管理和認知 * state:是否啟用該條規則 * waf:owasp標記 * action:執行動作 1. deny 拒絕當前請求 2. allow 放行該請求,且直接跳出所有的規則匹配,及后續的規則都不會匹配;比較 第3個規則是放行,第6個規則是攔截,3和6規則都滿足時,只會執行第3個規則 3. debug 記錄當前請求,一般用于調試使用,其會完整的記錄`request`的內容、以及`response`內容,存放在 `/opt/openresty(tengine)/openstar/logs/debug.log`;及基礎配置中的 `logs` 參數的路徑 4. rehtml 返回固定的 `html` 類型的`body`內容(`Content-Type:text/html`),一般可以配置一個JS跳轉的頁面,配置一個第三方要求的一個特定的驗證txt文件等等 5. refile 返回一個文件內容,返回的頭`Content-Type`可配置 文件名稱:保存在目錄`/opt/openresty(tengine)/openstar/index/`中的文件,及基本配置中`htmlPath`參數配置的路徑 文件類型:`Content-Type` 的配置,默認為:`text/html` 6. func 執行一個插件函數,插件函數可以直接返回內容,也可以添加參數,也可以進行簽名檢查等等 * hostname、uri 這2個規則的匹配和過去介紹的一樣 第一個參數:匹配的內容 第二個參數:匹配的方法(匹配符) 【參考匹配方式】 第三個參數:取反標記 * app_ext:整個內容是一個數組 高級規則組是高級規則配置的核心配置使用,因為其匹配的位置是 `request` 請求的任何位置,具體可以匹配的參數可以參考前面的 [匹配位置說明](http://www.hmoore.net/openstar/install/1136679) 子規則的寫法: ![](https://img.kancloud.cn/41/1a/411aa6051f0313641c8843e5f7fa6b99_517x505.png) ![](https://img.kancloud.cn/47/89/4789d855b13bf75aaf8a10a4e25b4456_536x523.png) ![](https://img.kancloud.cn/72/01/72011c685f3aee95fda4e103a172405f_524x510.png) 看到這幾個實例后,我在給大家總結一下: ![](https://img.kancloud.cn/7d/30/7d30cf16b81aae10b6dde7c03f06749f_475x386.png) 寫法比較復雜,一定要多多練習,后面也會結合配置實例進行講解 子規則組合后的理解: ``` #下面示例中,true 和 false 是每一條規則的匹配結果 true or false --- 理解一下 (true or false)==> true false or false and true --- 理解一下(false or false)and true ==> false and true ==> false false or false or true and false --- 理解一下(false or false or true)and false ==> true and false ==> false true or false or true and false or true --- (true or false or true) and (false or true) ==> true and true ==> true 注:or 連接符連接的上下規則可以理解為 ()括起來的,多個 or 連接時也是一樣,括號范圍到 連接符為 and 時截止!!! 當 and 連接符截止的規則組為 false 時,后面的規則是不會進匹配的,有效的提高性能,如第二個例子,其實際過程中,其不會執行 第三個 規則的匹配 ``` ## 刪除 刪除該條規則 ## 編輯 同添加規則相似,是對該條規則進行編輯操作 ## 保存: 保存該模塊規則到服務器json配置文件(防止重啟后配置丟失) 保存當前內存中 高級規則模塊(app_Mod) 保存到本地磁盤中(`/opt/openresty/openstar/conf_json/app_Mod.json`) 注:Slave 會自動保存配置到json文件!!! ## 配置示例 先看一下 demo 示例的幾個規則 ``` EG:假設本演示WAF的ip:192.168.10.56 [ { "state": "on", "des":"1-test-deny", "action": "deny", "waf":"other", "hostname": ["localhost",""], "uri": ["^/([\\w]{4}\\.html|deny\\.do|你好\\.html)$","jio"] # 基礎配置規則 host uri 匹配成功則拒絕請求(可以沒有 高級規則組) # 這里 域名 匹配的是 默認域名 localhost (及沒有匹配到任意域名時,訪問的默認server) # uri 使用正則的方式匹配這 4類 uri ,匹配成功就拒絕本次請求 # 訪問以下 uri 則攔截該請求 http://192.168.10.56/你好.html http://192.168.10.56/deny.do http://192.168.10.56/12x3.html }, { "state": "on", "des":"2-test-rehtml", "action": "rehtml", "waf":"cc", "rehtml": "<html>hi~!</html>", "hostname": ["localhost",""], "uri": ["/rehtml",""] # 基礎規則匹配成功 返回 固定的 html # 訪問 http://192.168.10.56/rehtml 將會看到rehtml 配置的內容 }, { "state": "on", "des":"3-test-refile", "waf":"cc", "action": "refile", "refile": ["2.txt","text/html"], "hostname": ["localhost",""], "uri": ["/refile",""] # 基礎規則匹配成功,返回文件 2.txt 的文件內容 # 訪問 http://192.168.10.56/refile 則會看到 文件 /opt/openresty/openstar/index/2.txt 文件的內容 # 其中文件路徑的配置就是在 高級配置 中參數 htmlPath 所配置的地址 }, { "state": "off", "des":"4-test-app_ext", "action": "deny", "waf":"other", "hostname": [["www.abc.com","localhost"],"list"], "uri": ["/api/.*","jio"], "app_ext":[ ["ip",[["106.37.236.170","1.1.1.1"],"list",true]] ] # 匹配域名等于 www.abc.com 和 localhost ,且uri 正則匹配 /api/.* 其訪問的ip 為 106.37.236.170 和 1.1.1.1時不做任何處理,其他的IP就拒絕其請求;一般用于后臺的 IP 訪問控制 }, { "state": "on", "des":"5-test-js_debug", "waf":"cc", "action": "refile", "refile": ["js_debug.txt","text/html"], "hostname": ["localhost",""], "uri": ["/api/debug",""], "app_ext":[ ["args",["true","@token@",["cctoken"],true]] ] # 域名匹配 localhost ,uri 匹配 /api/debug ,其GET參數 cctoken的內容 不等于 @token@ (WAF動態生成)時,返回固定的文件內容;前面在介紹 匹配方式 時有說過 # 可以看錄制的視頻教程,里面做了比較詳細的解釋 }, { "state": "on", "des":"6-test-len", "waf":"other", "action": "deny", "hostname": ["localhost",""], "uri": ["/len",""], "app_ext":[ ["args",[[5,20],"len",["arg_len"],true]] ] #域名匹配 localhost ,uri 匹配 /len ,其GET參數arg_len 其長度不在范圍[5,20](大于等于5,小于等于20)時,就執行攔截操作 # 訪問 http://192.168.10.56/len?arg_len=1111 攔截該請求 # 訪問 http://192.168.10.56/len?arg_len=01234567890123456789012 攔截該請求 # 訪問 http://192.168.10.56/len?arg_len=0123456 本條規則就不會攔截 }, { "state": "on", "des":"7-test-js_time", "waf":"other", "action": "refile", "refile":["js_time.txt","text/html"], "hostname": [["www.abc.com","localhost"],"list"], "uri": ["/api/time",""], "app_ext":[ ["args",["^[\\w]{6}$","jio",["keyby"],true]] ] # 域名匹配 www.abc.com 和 localhost ,uri 匹配 /api/time,其GET參數keyby內容不滿足正則 \w{6} 時,就執行攔截操作 # 詳細的解釋可以看錄制的視頻 }, { "state": "on", "des":"8-test-debug", "action": "debug", "hostname": ["localhost",""], "uri": ["/debug",""] # 域名匹配 localhost ,uri 匹配 /debug,執行 debug 記錄操作,不影響后續規則 # 記錄的請求數據在文件 /opt/openresty(tengine)/openstar/logs/debug.log # 其中文件存放的路徑也是在高級配置中參數 logPath 配置的路徑 }, { "state": "on", "des":"9-test-post_js_time", "waf":"cc", "action": "refile", "refile":["js_time.txt","text/html"], "hostname": [["www.abc.com","localhost"],"list"], "uri": ["/api/time",""], "app_ext":[ ["posts",["^[\\w]{6}$","jio",["p_key"],true]] ] # 域名匹配 www.abc.com 和 localhost ,uri 匹配 /api/time,其POST參數p_key的內容不滿足正則 \w{6} 時,就執行攔截操作 }, { "state": "on", "des":"10-test-post_form", "waf":"webshell", "action": "deny", "post_form":1024, "hostname": ["localhost",""], "uri": ["/api/test/debug",""], "app_ext":[ ["post_form",["\\.(jpg|jpeg|png|webp|gif)$","jio",["image0",2],true],"or"], ["post_form",["(;|-|/)","jio",["image0",2],false],"or"] ] # 本條規則是過濾 POST 表單的內容 # app_ext 第一條規則 匹配的是 表單名稱是 image0 的文件名匹配該條正則然后取反 # app_ext 第二條規則 同樣匹配 image0 文件名匹配"(;|-|/)" }, { "state": "on", "des":"11-test-func", "action": "func", "func": ["sign_generate",["http_ck_sign","md5","$uri","$http_time","isdifasdfksf"]], "hostname": ["localhost",""], "uri": ["/sign.test",""] # 本條規則是執行 插件函數 # sign_generate 是插件的函數名稱,后面的數據是傳遞給該插件的參數。 } ] ``` **高級規則配置極其復雜,后面我也會持續更新其他教程進行完善**
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看