You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/05/27 04:16:47 UTC

[GitHub] [incubator-apisix] shengnoah opened a new issue #1617: feature: support url check with regular expression matching

shengnoah opened a new issue #1617:
URL: https://github.com/apache/incubator-apisix/issues/1617


   ### Issue description
   Support url check with regular expression matching.
   If  url contains some specical characters and regular expression defined matching.
   Set dynamic proxy upstream point to  HTTTP Server A.
   If msimatch regular expression.
   Set dynamic proxy upstream point to  HTTTP Server B.
   
   
   ### Example
   
   URL: http://127.0.0.1/index.pht?a=<script>
   Regular expression: “\<(iframe|script|body|img|layer|div|meta|style|base|object|input)” 
   Match result: Yes, found a match string:"<script"  and  set dynamic proxy upstream point to HTTP server B.
    
   Upstream HTTP server A : accept user normal HTTP Service Requests.
   Upstream HTTP server B : accept user illegal requests.
   Syslog Server : open Syslog UDP listening port with logs data reception for the statistics.
   
   flow-process
   
   ![example](https://github.com/shengnoah/luaren/wiki/images/apisix_url_regular_matching.jpg)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-apisix] shengnoah commented on issue #1617: feature: support url check with regular expression matching and dynamic upstream selection

Posted by GitBox <gi...@apache.org>.
shengnoah commented on issue #1617:
URL: https://github.com/apache/incubator-apisix/issues/1617#issuecomment-645098912


   > plugins:
   > 
   > 1. allow-list
   > 2. block-list
   > 
   > we can implement the plugin by 3 steps:
   > 
   > step1: hit rules and set response code
   > 
   > ```
   > {
   >     uri_rules: [
   >         "(?:liuneng)&DeviceId=XDS3EFG756767676DXCVXV234234",
   >         "(?:zhaosi)&DeviceId=CDF7EFG1212345687XCEVXV678976",
   >     ],
   >     rejected_code: 403
   > }
   > ```
   > 
   > step2: hit rules and set specify upstream
   > 
   > ```
   > {
   >     uri_rules: [
   >         "(?:liuneng)&DeviceId=XDS3EFG756767676DXCVXV234234",
   >         "(?:zhaosi)&DeviceId=CDF7EFG1212345687XCEVXV678976",
   >     ],
   >     honey_pot: "https://apisix.com/testcase_one"
   > }
   > ```
   > 
   > step3: hit rules and write the log to specify `syslog` server
   > 
   > ```
   > {
   >     uri_rules: [
   >         "(?:liuneng)&DeviceId=XDS3EFG756767676DXCVXV234234",
   >         "(?:zhaosi)&DeviceId=CDF7EFG1212345687XCEVXV678976",
   >     ],
   >     honey_pot: "https://apisix.com/testcase_one",
   >     syslog_server: "udp://xxxx:2380/"
   > }
   > ```
   
   Maybe it's better to change the variable name. 
   
   uri_rules -> filter-rules
   Because not just filer URLs in future.
   
   honey_pot -> honeypot
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-apisix] shengnoah edited a comment on issue #1617: feature: support url check with regular expression matching and dynamic upstream selection

Posted by GitBox <gi...@apache.org>.
shengnoah edited a comment on issue #1617:
URL: https://github.com/apache/incubator-apisix/issues/1617#issuecomment-643849169


   ```
   {
       "uri_list:" [
           "/test?Username=laoli&DeviceId=XDS3EFG756767676DXCVXV234234"
       ],
       rules: {
           rule: (?:laoli)&DeviceId=XDS3EFG756767676DXCVXV234234
       },
       action: {
           OK_proxy_pass:https://iresty.com/testcase_one
           NG_proxy_pass:https://apisix.com/testcase_one
      }
   }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-apisix] moonming commented on issue #1617: feature: support url check with regular expression matching

Posted by GitBox <gi...@apache.org>.
moonming commented on issue #1617:
URL: https://github.com/apache/incubator-apisix/issues/1617#issuecomment-634555148


   @shengnoah I think Apache APISIX already support this, you can use https://github.com/api7/lua-resty-radixtree#operator-list to match uri with regex operator `~~`


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-apisix] membphis commented on issue #1617: feature: support url check with regular expression matching and dynamic upstream selection

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #1617:
URL: https://github.com/apache/incubator-apisix/issues/1617#issuecomment-644771686


   ![image](https://user-images.githubusercontent.com/6814606/84781689-b5dc3500-b019-11ea-9072-0d2396f4331b.png)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-apisix] shengnoah edited a comment on issue #1617: feature: support url check with regular expression matching and dynamic upstream selection

Posted by GitBox <gi...@apache.org>.
shengnoah edited a comment on issue #1617:
URL: https://github.com/apache/incubator-apisix/issues/1617#issuecomment-643849169


   ```
   {
       "uri_list:" [
           "/test?Username=liuneng&DeviceId=XDS3EFG756767676DXCVXV234234"
       ],
       rules: [
           "(?:liuneng)&DeviceId=XDS3EFG756767676DXCVXV234234",
           "(?:zhaosi)&DeviceId=CDF7EFG1212345687XCEVXV678976",
       ],
       action: {
           OK_proxy_pass:https://iresty.com/testcase_one
           NG_proxy_pass:https://apisix.com/testcase_one
      }
   }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-apisix] shengnoah commented on issue #1617: feature: support url check with regular expression matching and dynamic upstream selection

Posted by GitBox <gi...@apache.org>.
shengnoah commented on issue #1617:
URL: https://github.com/apache/incubator-apisix/issues/1617#issuecomment-643849169


   {
       "uri_list:" [
           "/test?Username=laoli&DeviceId=XDS3EFG756767676DXCVXV234234"
       ],
       rules: {
           rule:  (?:laoli)&DeviceId=XDS3EFG756767676DXCVXV234234
       },
       action: {
           OK_proxy_pass:https://iresty.com/testcase_one
           NG_proxy_pass:https://apisix.com/testcase_one
       }
   }


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-apisix] membphis commented on issue #1617: feature: support url check with regular expression matching and dynamic upstream selection

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #1617:
URL: https://github.com/apache/incubator-apisix/issues/1617#issuecomment-641084618


   @shengnoah you can write an example of this plugin. What do you think?
   
   ```
   {
       "uri_list": [
           "/foo/glay/*", "/foo/bar", "/foo/gloo/*"
       ],
       action: {
           reject_code: 200,
           delay: 10     # 1 sec
           body: xxxx
       }
   }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-apisix] shengnoah edited a comment on issue #1617: feature: support url check with regular expression matching and dynamic upstream selection

Posted by GitBox <gi...@apache.org>.
shengnoah edited a comment on issue #1617:
URL: https://github.com/apache/incubator-apisix/issues/1617#issuecomment-643849169


   ```
   {
       "uri_list:" [
           "/test?Username=liuneng&DeviceId=XDS3EFG756767676DXCVXV234234"
       ],
       rules: [
           "(?:liuneng)&DeviceId=XDS3EFG756767676DXCVXV234234",
           "(?:zhaosi)&DeviceId=XDS3EFG756767676DXCVXV234234",
       ],
       action: {
           OK_proxy_pass:https://iresty.com/testcase_one
           NG_proxy_pass:https://apisix.com/testcase_one
      }
   }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-apisix] shengnoah commented on issue #1617: feature: support url check with regular expression matching

Posted by GitBox <gi...@apache.org>.
shengnoah commented on issue #1617:
URL: https://github.com/apache/incubator-apisix/issues/1617#issuecomment-635066248


   Yeah , "operator-list" is OK.
   
   I think i shoud edit issue title,
   "support url check with regular expression matching  and  dynamic upstream selection"
   According to regular expressions match result to select a upstream server by the definition of users.
   
   > @shengnoah I think Apache APISIX already support this, you can use https://github.com/api7/lua-resty-radixtree#operator-list to match uri with regex operator `~~`
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-apisix] membphis commented on issue #1617: feature: support url check with regular expression matching and dynamic upstream selection

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #1617:
URL: https://github.com/apache/incubator-apisix/issues/1617#issuecomment-644787064


   step1:
   
   ```
   {
       uri_rules: [
           "(?:liuneng)&DeviceId=XDS3EFG756767676DXCVXV234234",
           "(?:zhaosi)&DeviceId=CDF7EFG1212345687XCEVXV678976",
       ],
       rejected_code: 403
   }
   ```
   
   step2:
   
   ```
   {
       uri_rules: [
           "(?:liuneng)&DeviceId=XDS3EFG756767676DXCVXV234234",
           "(?:zhaosi)&DeviceId=CDF7EFG1212345687XCEVXV678976",
       ],
       honey_pot: "https://apisix.com/testcase_one"
   }
   ```
   
   step3:
   
   ```
   {
       uri_rules: [
           "(?:liuneng)&DeviceId=XDS3EFG756767676DXCVXV234234",
           "(?:zhaosi)&DeviceId=CDF7EFG1212345687XCEVXV678976",
       ],
       honey_pot: "https://apisix.com/testcase_one",
       syslog_server: "udp://xxxx:2380/"
   }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-apisix] membphis edited a comment on issue #1617: feature: support url check with regular expression matching and dynamic upstream selection

Posted by GitBox <gi...@apache.org>.
membphis edited a comment on issue #1617:
URL: https://github.com/apache/incubator-apisix/issues/1617#issuecomment-644787064


   plugins:
   1. allow-list
   2. block-list
   
   we can implement the plugin by 3 steps:
   
   step1: hit rules and set response code
   
   ```
   {
       uri_rules: [
           "(?:liuneng)&DeviceId=XDS3EFG756767676DXCVXV234234",
           "(?:zhaosi)&DeviceId=CDF7EFG1212345687XCEVXV678976",
       ],
       rejected_code: 403
   }
   ```
   
   step2: hit rules and set specify upstream 
   
   ```
   {
       uri_rules: [
           "(?:liuneng)&DeviceId=XDS3EFG756767676DXCVXV234234",
           "(?:zhaosi)&DeviceId=CDF7EFG1212345687XCEVXV678976",
       ],
       honey_pot: "https://apisix.com/testcase_one"
   }
   ```
   
   step3: hit rules and write the log to specify `syslog` server
   
   ```
   {
       uri_rules: [
           "(?:liuneng)&DeviceId=XDS3EFG756767676DXCVXV234234",
           "(?:zhaosi)&DeviceId=CDF7EFG1212345687XCEVXV678976",
       ],
       honey_pot: "https://apisix.com/testcase_one",
       syslog_server: "udp://xxxx:2380/"
   }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org