[GitHub] [incubator-apisix] xxm404 commented on issue #1280: request help: How do I enable the plug-in when using the standalone model(local yaml)?
xxm404 commented on issue #1280: request help: How do I enable the plug-in when using the standalone model(local yaml)? URL: https://github.com/apache/incubator-apisix/issues/1280#issuecomment-599374485 > you can take a look at the test cases: https://github.com/apache/incubator-apisix/tree/master/t/config-center-yaml Modify nginx config directly? Can i enable the limit-req plugin by modify apisix.yaml? 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis commented on issue #1280: request help: 如何通过 apisix.yaml 配置文件开启插件
membphis commented on issue #1280: request help: 如何通过 apisix.yaml 配置文件开启插件 URL: https://github.com/apache/incubator-apisix/issues/1280#issuecomment-599346550 you can take a look at the test cases: https://github.com/apache/incubator-apisix/tree/master/t/config-center-yaml 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis commented on issue #1279: feature: eureka integration
membphis commented on issue #1279: feature: eureka integration URL: https://github.com/apache/incubator-apisix/issues/1279#issuecomment-599346293 related issue: https://github.com/apache/incubator-apisix/issues/804 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] xxm404 opened a new issue #1280: 如何通过 apisix.yaml 配置文件开启插件
xxm404 opened a new issue #1280: 如何通过 apisix.yaml 配置文件开启插件 URL: https://github.com/apache/incubator-apisix/issues/1280 ### Issue description 如何在不使用 `etcd` 的模式下,开启插件 ### Environment * apisix version 1.1 * OS: Ubuntu 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] qiujiayu opened a new issue #1279: feature: eureka integration
qiujiayu opened a new issue #1279: feature: eureka integration URL: https://github.com/apache/incubator-apisix/issues/1279 This is an idea about integrating APISIX with eureka: 1. Added a discovery property to the `apisix.core` module to extend various service discovery components, such as eureka; 2. Use the upstream_id of the route to associate the application name (`spring.application.name` in spring boot) 3. In `apisix.balancer`, according to the `upstream_id` of `route`, first find the application nodes in the configuration, and if it is not found, go to discovery; If you want to register APISIX with the registry, it will be more complicated. Do you have any requirements for this? 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis commented on a change in pull request #1275: Add multiple etcd address support.
membphis commented on a change in pull request #1275: Add multiple etcd address support. URL: https://github.com/apache/incubator-apisix/pull/1275#discussion_r392738555 ## File path: bin/apisix ## @@ -661,28 +661,32 @@ local function init_etcd(show_output) end local etcd_conf = yaml_conf.etcd -local uri = etcd_conf.host .. "/v2/keys" .. (etcd_conf.prefix or "") - local timeout = etcd_conf.timeout or 3 +local uri + +for _, host in ipairs(yaml_conf.etcd.host) do Review comment: this is wrong. If the user specifies multiple etcd addresses, these etcd instances should belong to one cluster. When we need to initialize etcd, as long as one of them is successfully initialized, it is considered successful. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis commented on a change in pull request #1275: Add multiple etcd address support.
membphis commented on a change in pull request #1275: Add multiple etcd address support. URL: https://github.com/apache/incubator-apisix/pull/1275#discussion_r392736830 ## File path: conf/config.yaml ## @@ -98,7 +98,10 @@ nginx_config: # config for render the template to genarate n - 'unix:' etcd: - host: "http://127.0.0.1:2379"; # etcd address + host: +- "http://127.0.0.1:2379"; # multiple etcd address Review comment: That is wrong. By default, there should be only one etcd address. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis commented on issue #1275: Add multiple etcd address support.
membphis commented on issue #1275: Add multiple etcd address support. URL: https://github.com/apache/incubator-apisix/pull/1275#issuecomment-599294660 I updated the resty-etcd right now. Please rebase your branch with APISIX master branch. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis merged pull request #1278: update resty-etcd to version 0.9 .
membphis merged pull request #1278: update resty-etcd to version 0.9 . URL: https://github.com/apache/incubator-apisix/pull/1278 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: us...@infra.apache.org With regards, Apache Git Services
[incubator-apisix] branch master updated: update resty-etcd to version 0.9 . (#1278)
This is an automated email from the ASF dual-hosted git repository. membphis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git The following commit(s) were added to refs/heads/master by this push: new 9837b80 update resty-etcd to version 0.9 . (#1278) 9837b80 is described below commit 9837b80ac51b4bbf43b1b530b5764bcf624eda27 Author: YuanSheng Wang AuthorDate: Mon Mar 16 08:46:30 2020 +0800 update resty-etcd to version 0.9 . (#1278) --- rockspec/apisix-master-0.rockspec | 2 +- t/plugin/proxy-cache.t| 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/rockspec/apisix-master-0.rockspec b/rockspec/apisix-master-0.rockspec index 9a07914..8b9a217 100644 --- a/rockspec/apisix-master-0.rockspec +++ b/rockspec/apisix-master-0.rockspec @@ -31,7 +31,7 @@ description = { dependencies = { "lua-resty-template = 1.9", -"lua-resty-etcd = 0.8", +"lua-resty-etcd = 0.9", "lua-resty-balancer = 0.02rc5", "lua-resty-ngxvar = 0.5", "lua-resty-jit-uuid = 0.0.7", diff --git a/t/plugin/proxy-cache.t b/t/plugin/proxy-cache.t index cb48517..dc49c95 100644 --- a/t/plugin/proxy-cache.t +++ b/t/plugin/proxy-cache.t @@ -618,4 +618,3 @@ GET /t qr/cache_zone invalid_disk_cache not found/ --- no_error_log [error] -
[GitHub] [incubator-apisix] membphis opened a new pull request #1278: update resty-etcd to version 0.9 .
membphis opened a new pull request #1278: update resty-etcd to version 0.9 . URL: https://github.com/apache/incubator-apisix/pull/1278 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis commented on issue #1277: doc: add correct link address for "etcd Clustering Guide" of incubator-apisix/README_CN.md
membphis commented on issue #1277: doc: add correct link address for "etcd Clustering Guide" of incubator-apisix/README_CN.md URL: https://github.com/apache/incubator-apisix/pull/1277#issuecomment-599286973 please update the English doc too https://github.com/apache/incubator-apisix/blob/master/README.md#features 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] Akayeshmantha edited a comment on issue #1275: Add multiple etcd address support.
Akayeshmantha edited a comment on issue #1275: Add multiple etcd address support. URL: https://github.com/apache/incubator-apisix/pull/1275#issuecomment-599270894 Hi @membphis Most of the test cases fails with the below log https://pastebin.com/KbBD6h5s Hm I have no clue is it because now we are defining set of etcd hosts it can't elect a leader ? Some help here would be great 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] Akayeshmantha edited a comment on issue #1275: Add multiple etcd address support.
Akayeshmantha edited a comment on issue #1275: Add multiple etcd address support. URL: https://github.com/apache/incubator-apisix/pull/1275#issuecomment-599270894 Hi @membphis Most of the test cases fails with the below log https://pastebin.com/KbBD6h5s Hm I have no clue is it because now we are defining set of etcd hosts it can't find a leader ? Some help here would be great 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] Akayeshmantha edited a comment on issue #1275: Add multiple etcd address support.
Akayeshmantha edited a comment on issue #1275: Add multiple etcd address support. URL: https://github.com/apache/incubator-apisix/pull/1275#issuecomment-599270894 Hi @membphis Most of the test cases fails with the below log should not match any line in error.log but matches line "2020/03/15 22:47:57 [error] 17269#17269: *169 [lua] config_etcd.lua:350: failed to fetch data from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/ssl?waitIndex=10100&wait=true&recursive=true err:timeout, etcd key: /apisix/ssl, context: ngx.timer" (req 0) # 2020/03/15 22:47:57 [error] 17269#17269: *171 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/global_rules?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *171 [lua] config_etcd.lua:205: waitdir key: /apisix/global_rules prev_index: 10100, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *171 [lua] config_etcd.lua:206: res: null, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *171 [lua] config_etcd.lua:350: failed to fetch data from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/global_rules?waitIndex=10100&wait=true&recursive=true err:timeout, etcd key: /apisix/global_rules, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *173 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/services?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *173 [lua] config_etcd.lua:205: waitdir key: /apisix/services prev_index: 10100, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *173 [lua] config_etcd.lua:206: res: null, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *173 [lua] config_etcd.lua:350: failed to fetch data from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/services?waitIndex=10100&wait=true&recursive=true err:timeout, etcd key: /apisix/services, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *175 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/proto?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer # ' # at /home/ayesh/Documents/API_ASPIX/incubator-apisix/../test-nginx/lib/Test/Nginx/Socket.pm line 1280. # Failed test 'TEST 9: invalid route: wrong count - pattern "[error]" should not match any line in error.log but matches line "2020/03/15 22:47:57 [error] 17269#17269: *171 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/global_rules?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer" (req 0) # 2020/03/15 22:47:57 [info] 17269#17269: *171 [lua] config_etcd.lua:205: waitdir key: /apisix/global_rules prev_index: 10100, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *171 [lua] config_etcd.lua:206: res: null, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *171 [lua] config_etcd.lua:350: failed to fetch data from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/global_rules?waitIndex=10100&wait=true&recursive=true err:timeout, etcd key: /apisix/global_rules, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *173 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/services?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *173 [lua] config_etcd.lua:205: waitdir key: /apisix/services prev_index: 10100, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *173 [lua] config_etcd.lua:206: res: null, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *173 [lua] config_etcd.lua:350: failed to fetch data from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/services?waitIndex=10100&wait=true&recursive=true err:timeout, etcd key: /apisix/services, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *175 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/proto?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *175 [lua] config_etcd.lua:205: waitdir key: /apisix/proto prev_index: 10100, context: ngx.timer # ' # at /home/ayesh/Documents/API_ASPIX/incubator-apisix/../test-nginx/lib/Test/Nginx/Socket.pm line 1280. Hm I have no clue is it because now we are defining set of etcd hosts it can't find a leader ? Some help here would be great This
[GitHub] [incubator-apisix] Akayeshmantha edited a comment on issue #1275: Add multiple etcd address support.
Akayeshmantha edited a comment on issue #1275: Add multiple etcd address support. URL: https://github.com/apache/incubator-apisix/pull/1275#issuecomment-599270894 Hi @membphis Most of the test cases fails with the below log ` should not match any line in error.log but matches line "2020/03/15 22:47:57 [error] 17269#17269: *169 [lua] config_etcd.lua:350: failed to fetch data from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/ssl?waitIndex=10100&wait=true&recursive=true err:timeout, etcd key: /apisix/ssl, context: ngx.timer" (req 0) # 2020/03/15 22:47:57 [error] 17269#17269: *171 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/global_rules?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *171 [lua] config_etcd.lua:205: waitdir key: /apisix/global_rules prev_index: 10100, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *171 [lua] config_etcd.lua:206: res: null, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *171 [lua] config_etcd.lua:350: failed to fetch data from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/global_rules?waitIndex=10100&wait=true&recursive=true err:timeout, etcd key: /apisix/global_rules, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *173 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/services?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *173 [lua] config_etcd.lua:205: waitdir key: /apisix/services prev_index: 10100, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *173 [lua] config_etcd.lua:206: res: null, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *173 [lua] config_etcd.lua:350: failed to fetch data from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/services?waitIndex=10100&wait=true&recursive=true err:timeout, etcd key: /apisix/services, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *175 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/proto?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer # ' # at /home/ayesh/Documents/API_ASPIX/incubator-apisix/../test-nginx/lib/Test/Nginx/Socket.pm line 1280. # Failed test 'TEST 9: invalid route: wrong count - pattern "[error]" should not match any line in error.log but matches line "2020/03/15 22:47:57 [error] 17269#17269: *171 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/global_rules?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer" (req 0) # 2020/03/15 22:47:57 [info] 17269#17269: *171 [lua] config_etcd.lua:205: waitdir key: /apisix/global_rules prev_index: 10100, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *171 [lua] config_etcd.lua:206: res: null, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *171 [lua] config_etcd.lua:350: failed to fetch data from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/global_rules?waitIndex=10100&wait=true&recursive=true err:timeout, etcd key: /apisix/global_rules, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *173 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/services?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *173 [lua] config_etcd.lua:205: waitdir key: /apisix/services prev_index: 10100, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *173 [lua] config_etcd.lua:206: res: null, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *173 [lua] config_etcd.lua:350: failed to fetch data from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/services?waitIndex=10100&wait=true&recursive=true err:timeout, etcd key: /apisix/services, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *175 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/proto?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *175 [lua] config_etcd.lua:205: waitdir key: /apisix/proto prev_index: 10100, context: ngx.timer # ' # at /home/ayesh/Documents/API_ASPIX/incubator-apisix/../test-nginx/lib/Test/Nginx/Socket.pm line 1280. ` Hm I have no clue is it because now we are defining set of etcd hosts it can't find a leader ? Some help here would be great ---
[GitHub] [incubator-apisix] Akayeshmantha commented on issue #1275: Add multiple etcd address support.
Akayeshmantha commented on issue #1275: Add multiple etcd address support. URL: https://github.com/apache/incubator-apisix/pull/1275#issuecomment-599270894 Hi @membphis Most of the test cases fails with the below log `" should not match any line in error.log but matches line "2020/03/15 22:47:57 [error] 17269#17269: *169 [lua] config_etcd.lua:350: failed to fetch data from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/ssl?waitIndex=10100&wait=true&recursive=true err:timeout, etcd key: /apisix/ssl, context: ngx.timer" (req 0) # 2020/03/15 22:47:57 [error] 17269#17269: *171 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/global_rules?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *171 [lua] config_etcd.lua:205: waitdir key: /apisix/global_rules prev_index: 10100, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *171 [lua] config_etcd.lua:206: res: null, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *171 [lua] config_etcd.lua:350: failed to fetch data from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/global_rules?waitIndex=10100&wait=true&recursive=true err:timeout, etcd key: /apisix/global_rules, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *173 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/services?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *173 [lua] config_etcd.lua:205: waitdir key: /apisix/services prev_index: 10100, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *173 [lua] config_etcd.lua:206: res: null, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *173 [lua] config_etcd.lua:350: failed to fetch data from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/services?waitIndex=10100&wait=true&recursive=true err:timeout, etcd key: /apisix/services, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *175 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/proto?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer # ' # at /home/ayesh/Documents/API_ASPIX/incubator-apisix/../test-nginx/lib/Test/Nginx/Socket.pm line 1280. # Failed test 'TEST 9: invalid route: wrong count - pattern "[error]" should not match any line in error.log but matches line "2020/03/15 22:47:57 [error] 17269#17269: *171 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/global_rules?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer" (req 0) # 2020/03/15 22:47:57 [info] 17269#17269: *171 [lua] config_etcd.lua:205: waitdir key: /apisix/global_rules prev_index: 10100, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *171 [lua] config_etcd.lua:206: res: null, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *171 [lua] config_etcd.lua:350: failed to fetch data from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/global_rules?waitIndex=10100&wait=true&recursive=true err:timeout, etcd key: /apisix/global_rules, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *173 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/services?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *173 [lua] config_etcd.lua:205: waitdir key: /apisix/services prev_index: 10100, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *173 [lua] config_etcd.lua:206: res: null, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *173 [lua] config_etcd.lua:350: failed to fetch data from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/services?waitIndex=10100&wait=true&recursive=true err:timeout, etcd key: /apisix/services, context: ngx.timer # 2020/03/15 22:47:57 [error] 17269#17269: *175 [lua] config_etcd.lua:77: waitdir(): failed to get key from etcd: fail request to: http://127.0.0.1:2379/v2/keys/apisix/proto?waitIndex=10100&wait=true&recursive=true err:timeout, context: ngx.timer # 2020/03/15 22:47:57 [info] 17269#17269: *175 [lua] config_etcd.lua:205: waitdir key: /apisix/proto prev_index: 10100, context: ngx.timer # ' # at /home/ayesh/Documents/API_ASPIX/incubator-apisix/../test-nginx/lib/Test/Nginx/Socket.pm line 1280. ` Hm I have no clue is it because now we are defining set of etcd hosts it can't find a leader ? Some help here would be great This
[GitHub] [incubator-apisix] sbritocorral opened a new pull request #1277: doc: add correct link address for "etcd Clustering Guide" of incubator-apisix/README_CN.md
sbritocorral opened a new pull request #1277: doc: add correct link address for "etcd Clustering Guide" of incubator-apisix/README_CN.md URL: https://github.com/apache/incubator-apisix/pull/1277 Resolves #1235 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis merged pull request #1258: Supplement admin-api-cn.md, add route/service/consumer/upstream/ssl definitions.
membphis merged pull request #1258: Supplement admin-api-cn.md, add route/service/consumer/upstream/ssl definitions. URL: https://github.com/apache/incubator-apisix/pull/1258 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: us...@infra.apache.org With regards, Apache Git Services
[incubator-apisix] branch master updated: doc: add route/service/consumer/upstream/ssl definitions to Admin API (#1258)
This is an automated email from the ASF dual-hosted git repository. membphis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git The following commit(s) were added to refs/heads/master by this push: new cade206 doc: add route/service/consumer/upstream/ssl definitions to Admin API (#1258) cade206 is described below commit cade206d5abceab359ce083347f7fbcc310e438b Author: Yousa AuthorDate: Sun Mar 15 22:42:09 2020 +0800 doc: add route/service/consumer/upstream/ssl definitions to Admin API (#1258) --- doc/admin-api-cn.md| 294 - doc/admin-api.md | 287 +++ doc/architecture-design.md | 2 + 3 files changed, 582 insertions(+), 1 deletion(-) diff --git a/doc/admin-api-cn.md b/doc/admin-api-cn.md index 1b61af1..890cb46 100644 --- a/doc/admin-api-cn.md +++ b/doc/admin-api-cn.md @@ -22,6 +22,10 @@ === * [Route](#route) +* [Service](#service) +* [Consumer](#consumer) +* [Upstream](#upstream) +* [SSL](#ssl) ## Route @@ -71,7 +75,29 @@ - 除了 `uri`/`uris` 是必选的之外,`plugins`、`upstream`/`upstream_id`、`service_id` 这三类必须选择其中至少一个。 - 对于同一类参数比如 `uri`与 `uris`,`upstream` 与 `upstream_id`,`host` 与 `hosts`,`remote_addr` 与 `remote_addrs` 等,是不能同时存在,二者只能选择其一。如果同时启用,接口会报错。 -示例: +route 对象 json 配置内容: + +```shell +{ +"id": "1", # id,非必填 +"uri": "/release/a",# uri 路径 +"uris": ["/a","/b"],# 一组 uri 路径, uri 与 uris 只需要有一个非空即可 +"methods": ["GET","POST"], # 可以填多个方法 +"host": "aa.com", # host 域名 +"hosts": ["a.com","b.com"], # 一组 host 域名, host 与 hosts 只需要有一个非空即可 +"plugins": {}, # 指定 route 绑定的插件 +"priority": 0, # apisix 支持多种匹配方式,可能会在一次匹配中同时匹配到多条路由,此时优先级高的优先匹配中 +"desc": "hello world", +"remote_addr": "127.0.0.1", # 客户端请求 IP 地址 +"remote_addrs": ["127.0.0.1"], # 一组客户端请求 IP 地址, remote_addr 与 remote_addrs 只需要有一个非空即可 +"vars": [], # 由一个或多个 {var, operator, val} 元素组成的列表 +"upstream_id": "1", # upstream 对象在 etcd 中的 id ,建议使用此值 +"upstream": {}, # upstream 信息对象,建议尽量不要使用 +"filter_func": "", # 用户自定义的过滤函数,非必填 +} +``` + +具体示例: ```shell # 创建一个路由 @@ -147,3 +173,269 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13 [Back to TOC](#目录) +## Service + +*地址*:/apisix/admin/services/{id} + +*说明*:`Service` 是某类 API 的抽象(也可以理解为一组 Route 的抽象)。它通常与上游服务抽象是一一对应的,`Route` +与 `Service` 之间,通常是 N:1 的关系。 + +> 请求方法: + +|名字 |请求 uri|请求 body|说明| +|-|-|--|--| +|GET |/apisix/admin/services/{id}|无|获取资源| +|PUT |/apisix/admin/services/{id}|{...}|根据 id 创建资源| +|POST |/apisix/admin/services |{...}|创建资源,id 由后台服务自动生成| +|DELETE |/apisix/admin/services/{id}|无|删除资源| +|PATCH|/apisix/admin/services/{id}/{path}|{...}|修改已有 Service 的部分内容,其他不涉及部分会原样保留。| + +> body 请求参数: + +|名字 |可选项 |类型 |说明|示例| +|-|-||---|| +|plugins |可选 |Plugin|详见 [Plugin](architecture-design-cn.md#plugin) || +|upstream | upstream 或 upstream_id 两个选一个 |Upstream|启用的 Upstream 配置,详见 [Upstream](architecture-design-cn.md#upstream)|| +|upstream_id| upstream 或 upstream_id 两个选一个 |Upstream|启用的 upstream id,详见 [Upstream](architecture-design-cn.md#upstream)|| +|desc |可选 |辅助 |标识服务名称、使用场景等。|| + +serivce 对象 json 配置内容: + +```shell +{ +"id": "1", # id +"plugins": {}, # 指定 service 绑定的插件 +"upstream_id": "1", # upstream 对象在 etcd 中的 id ,建议使用此值 +"upstream": {}, # upstream 信息对象,不建议使用 +"desc": "hello world", # service 描述 +} +``` + +具体示例: + +```shell +# 创建一个Service +$ curl http://127.0.0.1:9080/apisix/admin/services/201 -X PUT -i -d ' +{ +"plugins": { +"limit-count": { +"count": 2, +"time_window": 60, +"rejected_code": 503, +"key": "remote_addr" +} +}, +"upstream": { +"type": "roundrobin", +"nodes": { +"39.97.63.215:80": 1 +} +} +}' + +# 返回结果 + +HTTP/1.1 201 Created +Date: Thu, 26 Dec 2019 03:48:47 GMT +Content-Type: text/plain +Transfer-Encoding: chunked +Connection: keep-alive +Access-Control-Allow-Origin: * +Access-Control-Allow-Credentials: true +Access-Control-Expose-Headers: * +Access-Control-Max-Age: 3600 +Server: APISIX web server + +{"node":{"value":{"upstream":{"nodes":{"39.97.63.215:80":1},"type":"roundrobin"},"plugins":{"limit-count":{"time_window":60,"count":2,"rejected_code":503,"key":"remote_addr","policy":"local"}}},"createdIndex":60,"key":"\/apisix\/services\/201","modifiedIndex":60},"action":"set"} +``` + +> 应答参数 + +目前是直接返回与 etcd 交互后的结果。 + +[Back to TOC](#目录) + +## Consumer + +*地址*:/apisix/admin/consumers/{id} + +*说明*:Consumer 是某类服务的消费者,需与用户认证体系配合才能使用。 + +> 请求方法: + +|名字 |请求 uri|请求 body|说明| +|-|-|--|--| +|GET
[GitHub] [incubator-apisix] membphis commented on issue #1153: feature: support for proxy caching plugin based on disk.
membphis commented on issue #1153: feature: support for proxy caching plugin based on disk. URL: https://github.com/apache/incubator-apisix/pull/1153#issuecomment-599217208 merged, many thx @agile6v 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: us...@infra.apache.org With regards, Apache Git Services
[incubator-apisix] branch master updated: feature: support for proxy caching plugin based on disk. (#1153)
This is an automated email from the ASF dual-hosted git repository. membphis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git The following commit(s) were added to refs/heads/master by this push: new 864aa16 feature: support for proxy caching plugin based on disk. (#1153) 864aa16 is described below commit 864aa16e91abe559182982031931e54bb540aff5 Author: agile6v AuthorDate: Sun Mar 15 22:26:08 2020 +0800 feature: support for proxy caching plugin based on disk. (#1153) --- bin/apisix | 47 ++- conf/config.yaml | 16 + doc/README.md | 1 + doc/README_CN.md | 1 + doc/plugins/proxy-cache-cn.md | 146 + doc/plugins/proxy-cache.md | 146 + lua/apisix/core/ctx.lua| 18 +- lua/apisix/plugins/proxy-cache.lua | 272 t/APISIX.pm| 23 ++ t/admin/plugins.t | 2 +- t/debug/debug-mode.t | 1 + t/plugin/proxy-cache.t | 621 + 12 files changed, 1287 insertions(+), 7 deletions(-) diff --git a/bin/apisix b/bin/apisix index 1c4f266..2d21aa0 100755 --- a/bin/apisix +++ b/bin/apisix @@ -182,6 +182,22 @@ http { lua_shared_dict jwks 1m; # cache for JWKs lua_shared_dict introspection10m; # cache for JWT verification results +{% if proxy_cache then %} +# for proxy cache +{% for _, cache in ipairs(proxy_cache.zones) do %} +proxy_cache_path {* cache.disk_path *} levels={* cache.cache_levels *} keys_zone={* cache.name *}:{* cache.memory_size *} inactive=1d max_size={* cache.disk_size *}; +{% end %} +{% end %} + +{% if proxy_cache then %} +# for proxy cache +map $upstream_cache_zone $upstream_cache_zone_info { +{% for _, cache in ipairs(proxy_cache.zones) do %} +{* cache.name *} {* cache.disk_path *},{* cache.cache_levels *}; +{% end %} +} +{% end %} + lua_ssl_verify_depth 5; ssl_session_timeout 86400; @@ -375,6 +391,8 @@ http { proxy_pass_header Server; proxy_pass_header Date; +### the following x-forwarded-* headers is to send to upstream server + set $var_x_forwarded_for$remote_addr; set $var_x_forwarded_proto $scheme; set $var_x_forwarded_host $host; @@ -398,7 +416,34 @@ http { proxy_set_header X-Forwarded-Host $var_x_forwarded_host; proxy_set_header X-Forwarded-Port $var_x_forwarded_port; -proxy_pass $upstream_scheme://apisix_backend$upstream_uri; +{% if proxy_cache then %} +### the following configuration is to cache response content from upstream server + +set $upstream_cache_zoneoff; +set $upstream_cache_key ''; +set $upstream_cache_bypass ''; +set $upstream_no_cache ''; +set $upstream_hdr_expires ''; +set $upstream_hdr_cache_control ''; + +proxy_cache $upstream_cache_zone; +proxy_cache_valid any {% if proxy_cache and proxy_cache.cache_ttl then %} {* proxy_cache.cache_ttl *} {% else %} 5s {% end %}; +proxy_cache_min_uses1; +proxy_cache_methods GET HEAD; +proxy_cache_lock_timeout5s; +proxy_cache_use_stale off; +proxy_cache_key $upstream_cache_key; +proxy_no_cache $upstream_no_cache; +proxy_cache_bypass $upstream_cache_bypass; + +proxy_hide_header Cache-Control; +proxy_hide_header Expires; +add_header Cache-Control $upstream_hdr_cache_control; +add_header Expires $upstream_hdr_expires; +add_header Apisix-Cache-Status $upstream_cache_status always; +{% end %} + +proxy_pass $upstream_scheme://apisix_backend$upstream_uri; header_filter_by_lua_block { apisix.http_header_filter_phase() diff --git a/conf/config.yaml b/conf/config.yaml index 8c1beb2..4bb942d 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -35,6 +35,21 @@ apisix: # enable_tcp_pp: true # Enable the proxy protocol for tcp proxy, it works for stream_proxy.tcp option # enable_tcp_pp_to_upstream: true # Enables the proxy protocol to the upstream server + proxy_cache: # Proxy Caching configuration +cache_ttl: 10s # The default caching time if the upstream does not specify the cache time +zones:
[GitHub] [incubator-apisix] membphis merged pull request #1153: feature: support for proxy caching plugin based on disk.
membphis merged pull request #1153: feature: support for proxy caching plugin based on disk. URL: https://github.com/apache/incubator-apisix/pull/1153 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis closed issue #1127: Feature: introduce proxy caching plugin
membphis closed issue #1127: Feature: introduce proxy caching plugin URL: https://github.com/apache/incubator-apisix/issues/1127 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis commented on a change in pull request #1258: Supplement admin-api-cn.md, add route/service/consumer/upstream/ssl definitions.
membphis commented on a change in pull request #1258: Supplement admin-api-cn.md, add route/service/consumer/upstream/ssl definitions. URL: https://github.com/apache/incubator-apisix/pull/1258#discussion_r392678465 ## File path: doc/admin-api-cn.md ## @@ -71,7 +75,29 @@ - 除了 `uri`/`uris` 是必选的之外,`plugins`、`upstream`/`upstream_id`、`service_id` 这三类必须选择其中至少一个。 - 对于同一类参数比如 `uri`与 `uris`,`upstream` 与 `upstream_id`,`host` 与 `hosts`,`remote_addr` 与 `remote_addrs` 等,是不能同时存在,二者只能选择其一。如果同时启用,接口会报错。 -示例: +route 对象 json 配置内容: + +```json Review comment: ![image](https://user-images.githubusercontent.com/6814606/76703265-7432aa00-670b-11ea-8a41-4370acda4d4e.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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] Miss-you commented on a change in pull request #1258: Supplement admin-api-cn.md, add route/service/consumer/upstream/ssl definitions.
Miss-you commented on a change in pull request #1258: Supplement admin-api-cn.md, add route/service/consumer/upstream/ssl definitions. URL: https://github.com/apache/incubator-apisix/pull/1258#discussion_r392678155 ## File path: doc/admin-api-cn.md ## @@ -71,7 +75,29 @@ - 除了 `uri`/`uris` 是必选的之外,`plugins`、`upstream`/`upstream_id`、`service_id` 这三类必须选择其中至少一个。 - 对于同一类参数比如 `uri`与 `uris`,`upstream` 与 `upstream_id`,`host` 与 `hosts`,`remote_addr` 与 `remote_addrs` 等,是不能同时存在,二者只能选择其一。如果同时启用,接口会报错。 -示例: +route 对象 json 配置内容: + +```json Review comment: Why is "```shell" better? And I have corrected it. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis commented on issue #1153: feature: support for proxy caching plugin based on disk.
membphis commented on issue #1153: feature: support for proxy caching plugin based on disk. URL: https://github.com/apache/incubator-apisix/pull/1153#issuecomment-599215439 LGTM, we can merge it after run the test cases. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis commented on issue #1275: Add multiple etcd address support.
membphis commented on issue #1275: Add multiple etcd address support. URL: https://github.com/apache/incubator-apisix/pull/1275#issuecomment-599210892 > is it a mock one or a real etcd db running ? It is a real etcd, the same as your local ENV. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk.
membphis commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk. URL: https://github.com/apache/incubator-apisix/pull/1153#discussion_r392673996 ## File path: t/plugin/proxy-cache.t ## @@ -0,0 +1,630 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +use t::APISIX 'no_plan'; + +repeat_each(1); +no_long_string(); +no_shuffle(); +no_root_location(); +log_level('info'); + +add_block_preprocessor(sub { +my ($block) = @_; + +my $http_config = $block->http_config // <<_EOC_; + +# for proxy cache +proxy_cache_path /tmp/disk_cache_one levels=1:2 keys_zone=disk_cache_one:50m inactive=1d max_size=1G; +proxy_cache_path /tmp/disk_cache_two levels=1:2 keys_zone=disk_cache_two:50m inactive=1d max_size=1G; + +# for proxy cache +map \$upstream_cache_zone \$upstream_cache_zone_info { +disk_cache_one /tmp/disk_cache_one,1:2; +disk_cache_two /tmp/disk_cache_two,1:2; +} + +server { +listen 1986; +server_tokens off; + +location / { +expires 60s; +return 200 "hello world!"; +} + +location /hello-not-found { +return 404; +} +} +_EOC_ + +$block->set_value("http_config", $http_config); +}); + +run_tests; + +__DATA__ + +=== TEST 1: sanity check (missing required field) +--- config + location /t { + content_by_lua_block { + local t = require("lib.test_admin").test + local code, body = t('/apisix/admin/routes/1', +ngx.HTTP_PUT, +[[{ +"plugins": { +"proxy-cache": { + "cache_bypass": ["$arg_bypass"], + "cache_method": ["GET"], + "cache_http_status": [200], + "hide_cache_headers": true, + "no_cache": ["$arg_no_cache"] +} +}, +"upstream": { +"nodes": { +"127.0.0.1:1980": 1 +}, +"type": "roundrobin" +}, +"uri": "/hello" + }]] + ) + + if code >= 300 then + ngx.status = code + end + ngx.say(body) + } + } +--- request +GET /t +--- error_code: 400 +--- response_body eval +qr/failed to check the configuration of plugin proxy-cache/ +--- no_error_log +[error] + + + +=== TEST 2: sanity check (invalid type for cache_method) +--- config + location /t { + content_by_lua_block { + local t = require("lib.test_admin").test + local code, body = t('/apisix/admin/routes/1', +ngx.HTTP_PUT, +[[{ +"plugins": { +"proxy-cache": { + "cache_zone": "disk_cache_one", + "cache_bypass": ["$arg_bypass"], + "cache_method": "GET", + "cache_http_status": [200], + "hide_cache_headers": true, + "no_cache": ["$arg_no_cache"] +} +}, +"upstream": { +"nodes": { +"127.0.0.1:1980": 1 +}, +"type": "roundrobin" +}, +"uri": "/hello" + }]] + ) + + if code >= 300 then + ngx.status = code + end + ngx.say(body) + } + } +--- request +GET /t +--- error_code: 400 +--- response_body eval +qr/failed to check the configuration of plugin proxy-cache/ +--- no_error_log +[error] + + + +=== TEST 3: sanity check (invalid type for cache_key) +--- config +
[GitHub] [incubator-apisix] Akayeshmantha commented on issue #1275: Add multiple etcd address support.
Akayeshmantha commented on issue #1275: Add multiple etcd address support. URL: https://github.com/apache/incubator-apisix/pull/1275#issuecomment-599210432 @membphis test cases fails in https://github.com/apache/incubator-apisix/blob/master/lua/apisix/core/config_etcd.lua#L350 How the etcd db loaded for the travis encironemnt is it a mock one or a real etcd db running ? 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk.
membphis commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk. URL: https://github.com/apache/incubator-apisix/pull/1153#discussion_r392673846 ## File path: lua/apisix/plugins/proxy-cache.lua ## @@ -0,0 +1,259 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one or more +-- contributor license agreements. See the NOTICE file distributed with +-- this work for additional information regarding copyright ownership. +-- The ASF licenses this file to You under the Apache License, Version 2.0 +-- (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + +local core = require("apisix.core") +local ngx_re = require("ngx.re") +local tab_insert = table.insert +local tab_concat = table.concat +local string = string +local io_open = io.open +local io_close = io.close +local ngx = ngx +local os = os +local ipairs = ipairs +local pairs = pairs +local tonumber = tonumber + +local plugin_name = "proxy-cache" + +local schema = { +type = "object", +properties = { +cache_zone = { +type = "string", +minLength = 1 +}, +cache_key = { +type = "array", +minItems = 1, +items = { +description = "a key for caching", +type = "string", +pattern = [[(^[^\$].+$|^\$[0-9a-zA-Z_]+$)]], +}, +default = {"$host", "$request_uri"} Review comment: ok, you are right 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] agile6v commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk.
agile6v commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk. URL: https://github.com/apache/incubator-apisix/pull/1153#discussion_r392672970 ## File path: t/plugin/proxy-cache.t ## @@ -0,0 +1,630 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +use t::APISIX 'no_plan'; + +repeat_each(1); +no_long_string(); +no_shuffle(); +no_root_location(); +log_level('info'); + +add_block_preprocessor(sub { +my ($block) = @_; + +my $http_config = $block->http_config // <<_EOC_; + +# for proxy cache +proxy_cache_path /tmp/disk_cache_one levels=1:2 keys_zone=disk_cache_one:50m inactive=1d max_size=1G; +proxy_cache_path /tmp/disk_cache_two levels=1:2 keys_zone=disk_cache_two:50m inactive=1d max_size=1G; + +# for proxy cache +map \$upstream_cache_zone \$upstream_cache_zone_info { +disk_cache_one /tmp/disk_cache_one,1:2; +disk_cache_two /tmp/disk_cache_two,1:2; +} + +server { +listen 1986; +server_tokens off; + +location / { +expires 60s; +return 200 "hello world!"; +} + +location /hello-not-found { +return 404; +} +} +_EOC_ + +$block->set_value("http_config", $http_config); +}); + +run_tests; + +__DATA__ + +=== TEST 1: sanity check (missing required field) +--- config + location /t { + content_by_lua_block { + local t = require("lib.test_admin").test + local code, body = t('/apisix/admin/routes/1', +ngx.HTTP_PUT, +[[{ +"plugins": { +"proxy-cache": { + "cache_bypass": ["$arg_bypass"], + "cache_method": ["GET"], + "cache_http_status": [200], + "hide_cache_headers": true, + "no_cache": ["$arg_no_cache"] +} +}, +"upstream": { +"nodes": { +"127.0.0.1:1980": 1 +}, +"type": "roundrobin" +}, +"uri": "/hello" + }]] + ) + + if code >= 300 then + ngx.status = code + end + ngx.say(body) + } + } +--- request +GET /t +--- error_code: 400 +--- response_body eval +qr/failed to check the configuration of plugin proxy-cache/ +--- no_error_log +[error] + + + +=== TEST 2: sanity check (invalid type for cache_method) +--- config + location /t { + content_by_lua_block { + local t = require("lib.test_admin").test + local code, body = t('/apisix/admin/routes/1', +ngx.HTTP_PUT, +[[{ +"plugins": { +"proxy-cache": { + "cache_zone": "disk_cache_one", + "cache_bypass": ["$arg_bypass"], + "cache_method": "GET", + "cache_http_status": [200], + "hide_cache_headers": true, + "no_cache": ["$arg_no_cache"] +} +}, +"upstream": { +"nodes": { +"127.0.0.1:1980": 1 +}, +"type": "roundrobin" +}, +"uri": "/hello" + }]] + ) + + if code >= 300 then + ngx.status = code + end + ngx.say(body) + } + } +--- request +GET /t +--- error_code: 400 +--- response_body eval +qr/failed to check the configuration of plugin proxy-cache/ +--- no_error_log +[error] + + + +=== TEST 3: sanity check (invalid type for cache_key) +--- config + l
[GitHub] [incubator-apisix] sshniro commented on issue #1276: add more test cases for oauth plugin
sshniro commented on issue #1276: add more test cases for oauth plugin URL: https://github.com/apache/incubator-apisix/issues/1276#issuecomment-599206961 Sure, will add a test case with a valid cert and a token with an indefinite expiry time, 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] moonming merged pull request #1266: Adding support to public key based introspection for OAuth plugin
moonming merged pull request #1266: Adding support to public key based introspection for OAuth plugin URL: https://github.com/apache/incubator-apisix/pull/1266 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: us...@infra.apache.org With regards, Apache Git Services
[incubator-apisix] branch master updated: feature: adding support to public key based introspection for OAuth plugin (#1266)
This is an automated email from the ASF dual-hosted git repository. wenming pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git The following commit(s) were added to refs/heads/master by this push: new c1df18f feature: adding support to public key based introspection for OAuth plugin (#1266) c1df18f is described below commit c1df18f769d181cbdb1cff27012e621fa418f5f6 Author: Nirojan Selvanathan AuthorDate: Sun Mar 15 13:40:10 2020 +0100 feature: adding support to public key based introspection for OAuth plugin (#1266) --- doc/plugins/oauth.md | 39 +++ lua/apisix/plugins/openid-connect.lua | 20 ++ 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/doc/plugins/oauth.md b/doc/plugins/oauth.md index 3ecfeea..3b3f0e6 100644 --- a/doc/plugins/oauth.md +++ b/doc/plugins/oauth.md @@ -42,6 +42,8 @@ The OAuth 2 / Open ID Connect(OIDC) plugin provides authentication and introspec |ssl_verify |optional |default is `false`| |introspection_endpoint |optional |URL of the token verification endpoint of the identity server| |introspection_endpoint_auth_method |optional |Authentication method name for token introspection | +|public_key |optional |The public key to verify the token | +|token_signing_alg_values_expected |optional |Algorithm used to sign the token | ### Token Introspection @@ -87,6 +89,43 @@ The following command can be used to access the new route. curl -i -X GET http://127.0.0.1:9080/get -H "Host: httpbin.org" -H "Authorization: Bearer {replace_jwt_token}" ``` + Introspecting with public key + +You can also provide the public key of the JWT token to verify the token. In case if you have provided a public key and +a token introspection endpoint, the public key workflow will be executed instead of verifying with the identity server. +This method can be used if you want to reduce additional network calls and to speedup the process. + +The following configurations shows how to add a public key introspection to a route. + +```bash +curl http://127.0.0.1:9080/apisix/admin/routes/5 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "uri": "/get", + "plugins": { +"proxy-rewrite": { + "scheme": "https" +}, +"openid-connect": { + "client_id": "api_six_client_id", + "client_secret": "client_secret_code", + "discovery": "full_URL_of_the_discovery_endpoint", + "bearer_only": true, + "realm": "master", + "token_signing_alg_values_expected": "RS256", + "public_key" : "-BEGIN CERTIFICATE- +{public_key} +-END CERTIFICATE-" +} + }, + "upstream": { +"type": "roundrobin", +"nodes": { + "httpbin.org:443": 1 +} + } +}' +``` + ## Troubleshooting Check/modify the DNS settings (`conf/config.yaml) if APISIX cannot resolve/connect to the identity provider. diff --git a/lua/apisix/plugins/openid-connect.lua b/lua/apisix/plugins/openid-connect.lua index 17a0538..6a93226 100644 --- a/lua/apisix/plugins/openid-connect.lua +++ b/lua/apisix/plugins/openid-connect.lua @@ -39,6 +39,8 @@ local schema = { realm = {type = "string"}, -- default is apisix logout_path = {type = "string"}, -- default is /logout redirect_uri = {type = "string"}, -- default is ngx.var.request_uri +public_key = {type = "string"}, +token_signing_alg_values_expected = {type = "string"} }, required = {"client_id", "client_secret", "discovery"} } @@ -105,10 +107,20 @@ end local function introspect(ctx, conf) if has_bearer_access_token(ctx) or conf.bearer_only then -local res, err = openidc.introspect(conf) -if res then -return res +local res, err + +if conf.public_key then +res, err = openidc.bearer_jwt_verify(conf) +if res then +return res +end +else +res, err = openidc.introspect(conf) +if res then +return res +end end + if conf.bearer_only then ngx.header["WWW-Authenticate"] = 'Bearer realm="' .. conf.realm .. '",error="' .. err .. '"' @@ -132,7 +144,7 @@ function _M.access(conf, ctx) end local response, err -if conf.introspection_endpoint then +if conf.introspection_endpoint or conf.public_key then response, err = introspect(ctx, conf) if err then core.log.error("failed to introspect in openidc: ", err)
[GitHub] [incubator-apisix] moonming closed issue #1242: Feature: OAuth public key based introspection for APISIX
moonming closed issue #1242: Feature: OAuth public key based introspection for APISIX URL: https://github.com/apache/incubator-apisix/issues/1242 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] moonming opened a new issue #1276: add more test cases for oauth plugin
moonming opened a new issue #1276: add more test cases for oauth plugin URL: https://github.com/apache/incubator-apisix/issues/1276 we'd better add more test cases for this plugin. I will merge first. _Originally posted by @moonming in https://github.com/apache/incubator-apisix/pull/1266#issuecomment-599205012_ 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] moonming commented on issue #1266: Adding support to public key based introspection for OAuth plugin
moonming commented on issue #1266: Adding support to public key based introspection for OAuth plugin URL: https://github.com/apache/incubator-apisix/pull/1266#issuecomment-599205012 we'd better add more test cases for this plugin. I will merge first. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] agile6v commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk.
agile6v commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk. URL: https://github.com/apache/incubator-apisix/pull/1153#discussion_r392669384 ## File path: lua/apisix/plugins/proxy-cache.lua ## @@ -0,0 +1,259 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one or more +-- contributor license agreements. See the NOTICE file distributed with +-- this work for additional information regarding copyright ownership. +-- The ASF licenses this file to You under the Apache License, Version 2.0 +-- (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + +local core = require("apisix.core") +local ngx_re = require("ngx.re") +local tab_insert = table.insert +local tab_concat = table.concat +local string = string +local io_open = io.open +local io_close = io.close +local ngx = ngx +local os = os +local ipairs = ipairs +local pairs = pairs +local tonumber = tonumber + +local plugin_name = "proxy-cache" + +local schema = { +type = "object", +properties = { +cache_zone = { +type = "string", +minLength = 1 +}, +cache_key = { +type = "array", +minItems = 1, +items = { +description = "a key for caching", +type = "string", +pattern = [[(^[^\$].+$|^\$[0-9a-zA-Z_]+$)]], +}, +default = {"$host", "$request_uri"} Review comment: Currently the default behavior is to convert HEAD to GET request. See also: http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_convert_head The conversation is the default behavior before introducing the proxy_cache_convert_header directive. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis merged pull request #1270: travis(osx): install the redis by brew.
membphis merged pull request #1270: travis(osx): install the redis by brew. URL: https://github.com/apache/incubator-apisix/pull/1270 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis closed issue #1213: bug(CI): failed to install redis in OSX system when running test cases.
membphis closed issue #1213: bug(CI): failed to install redis in OSX system when running test cases. URL: https://github.com/apache/incubator-apisix/issues/1213 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: us...@infra.apache.org With regards, Apache Git Services
[incubator-apisix] branch master updated (12bf2b4 -> d347cae)
This is an automated email from the ASF dual-hosted git repository. membphis pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git. from 12bf2b4 update resty-radixtree to version v1.8. (#1271) add d347cae travis(osx): install the redis by brew. (#1270) No new revisions were added by this update. Summary of changes: .travis.yml | 6 -- .travis/linux_openresty_runner.sh | 2 ++ .travis/linux_tengine_runner.sh | 2 ++ .travis/osx_openresty_runner.sh | 32 +--- 4 files changed, 13 insertions(+), 29 deletions(-)
[GitHub] [incubator-apisix] membphis commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk.
membphis commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk. URL: https://github.com/apache/incubator-apisix/pull/1153#discussion_r392666263 ## File path: lua/apisix/plugins/proxy-cache.lua ## @@ -0,0 +1,259 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one or more +-- contributor license agreements. See the NOTICE file distributed with +-- this work for additional information regarding copyright ownership. +-- The ASF licenses this file to You under the Apache License, Version 2.0 +-- (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + +local core = require("apisix.core") +local ngx_re = require("ngx.re") +local tab_insert = table.insert +local tab_concat = table.concat +local string = string +local io_open = io.open +local io_close = io.close +local ngx = ngx +local os = os +local ipairs = ipairs +local pairs = pairs +local tonumber = tonumber + +local plugin_name = "proxy-cache" + +local schema = { +type = "object", +properties = { +cache_zone = { +type = "string", +minLength = 1 +}, +cache_key = { +type = "array", +minItems = 1, +items = { +description = "a key for caching", +type = "string", +pattern = [[(^[^\$].+$|^\$[0-9a-zA-Z_]+$)]], +}, +default = {"$host", "$request_uri"} Review comment: The response data of the HEAD and GET methods are different. So I think we better add `method` to the cache key. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] Akayeshmantha opened a new pull request #1275: Add multiple etcd address support.
Akayeshmantha opened a new pull request #1275: Add multiple etcd address support. URL: https://github.com/apache/incubator-apisix/pull/1275 Add multiple etcd address support ### Issues resolved Fix #1231 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk.
membphis commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk. URL: https://github.com/apache/incubator-apisix/pull/1153#discussion_r392666086 ## File path: t/plugin/proxy-cache.t ## @@ -0,0 +1,630 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +use t::APISIX 'no_plan'; + +repeat_each(1); +no_long_string(); +no_shuffle(); +no_root_location(); +log_level('info'); + +add_block_preprocessor(sub { +my ($block) = @_; + +my $http_config = $block->http_config // <<_EOC_; + +# for proxy cache +proxy_cache_path /tmp/disk_cache_one levels=1:2 keys_zone=disk_cache_one:50m inactive=1d max_size=1G; +proxy_cache_path /tmp/disk_cache_two levels=1:2 keys_zone=disk_cache_two:50m inactive=1d max_size=1G; + +# for proxy cache +map \$upstream_cache_zone \$upstream_cache_zone_info { +disk_cache_one /tmp/disk_cache_one,1:2; +disk_cache_two /tmp/disk_cache_two,1:2; +} + +server { +listen 1986; +server_tokens off; + +location / { +expires 60s; +return 200 "hello world!"; +} + +location /hello-not-found { +return 404; +} +} +_EOC_ + +$block->set_value("http_config", $http_config); +}); + +run_tests; + +__DATA__ + +=== TEST 1: sanity check (missing required field) +--- config + location /t { + content_by_lua_block { + local t = require("lib.test_admin").test + local code, body = t('/apisix/admin/routes/1', +ngx.HTTP_PUT, +[[{ +"plugins": { +"proxy-cache": { + "cache_bypass": ["$arg_bypass"], + "cache_method": ["GET"], + "cache_http_status": [200], + "hide_cache_headers": true, + "no_cache": ["$arg_no_cache"] +} +}, +"upstream": { +"nodes": { +"127.0.0.1:1980": 1 +}, +"type": "roundrobin" +}, +"uri": "/hello" + }]] + ) + + if code >= 300 then + ngx.status = code + end + ngx.say(body) + } + } +--- request +GET /t +--- error_code: 400 +--- response_body eval +qr/failed to check the configuration of plugin proxy-cache/ +--- no_error_log +[error] + + + +=== TEST 2: sanity check (invalid type for cache_method) +--- config + location /t { + content_by_lua_block { + local t = require("lib.test_admin").test + local code, body = t('/apisix/admin/routes/1', +ngx.HTTP_PUT, +[[{ +"plugins": { +"proxy-cache": { + "cache_zone": "disk_cache_one", + "cache_bypass": ["$arg_bypass"], + "cache_method": "GET", + "cache_http_status": [200], + "hide_cache_headers": true, + "no_cache": ["$arg_no_cache"] +} +}, +"upstream": { +"nodes": { +"127.0.0.1:1980": 1 +}, +"type": "roundrobin" +}, +"uri": "/hello" + }]] + ) + + if code >= 300 then + ngx.status = code + end + ngx.say(body) + } + } +--- request +GET /t +--- error_code: 400 +--- response_body eval +qr/failed to check the configuration of plugin proxy-cache/ +--- no_error_log +[error] + + + +=== TEST 3: sanity check (invalid type for cache_key) +--- config +
[GitHub] [incubator-apisix] agile6v commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk.
agile6v commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk. URL: https://github.com/apache/incubator-apisix/pull/1153#discussion_r392660022 ## File path: t/plugin/proxy-cache.t ## @@ -0,0 +1,630 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +use t::APISIX 'no_plan'; + +repeat_each(1); +no_long_string(); +no_shuffle(); +no_root_location(); +log_level('info'); + +add_block_preprocessor(sub { +my ($block) = @_; + +my $http_config = $block->http_config // <<_EOC_; + +# for proxy cache +proxy_cache_path /tmp/disk_cache_one levels=1:2 keys_zone=disk_cache_one:50m inactive=1d max_size=1G; +proxy_cache_path /tmp/disk_cache_two levels=1:2 keys_zone=disk_cache_two:50m inactive=1d max_size=1G; + +# for proxy cache +map \$upstream_cache_zone \$upstream_cache_zone_info { +disk_cache_one /tmp/disk_cache_one,1:2; +disk_cache_two /tmp/disk_cache_two,1:2; +} + +server { +listen 1986; +server_tokens off; + +location / { +expires 60s; +return 200 "hello world!"; +} + +location /hello-not-found { +return 404; +} +} +_EOC_ + +$block->set_value("http_config", $http_config); +}); + +run_tests; + +__DATA__ + +=== TEST 1: sanity check (missing required field) +--- config + location /t { + content_by_lua_block { + local t = require("lib.test_admin").test + local code, body = t('/apisix/admin/routes/1', +ngx.HTTP_PUT, +[[{ +"plugins": { +"proxy-cache": { + "cache_bypass": ["$arg_bypass"], + "cache_method": ["GET"], + "cache_http_status": [200], + "hide_cache_headers": true, + "no_cache": ["$arg_no_cache"] +} +}, +"upstream": { +"nodes": { +"127.0.0.1:1980": 1 +}, +"type": "roundrobin" +}, +"uri": "/hello" + }]] + ) + + if code >= 300 then + ngx.status = code + end + ngx.say(body) + } + } +--- request +GET /t +--- error_code: 400 +--- response_body eval +qr/failed to check the configuration of plugin proxy-cache/ +--- no_error_log +[error] + + + +=== TEST 2: sanity check (invalid type for cache_method) +--- config + location /t { + content_by_lua_block { + local t = require("lib.test_admin").test + local code, body = t('/apisix/admin/routes/1', +ngx.HTTP_PUT, +[[{ +"plugins": { +"proxy-cache": { + "cache_zone": "disk_cache_one", + "cache_bypass": ["$arg_bypass"], + "cache_method": "GET", + "cache_http_status": [200], + "hide_cache_headers": true, + "no_cache": ["$arg_no_cache"] +} +}, +"upstream": { +"nodes": { +"127.0.0.1:1980": 1 +}, +"type": "roundrobin" +}, +"uri": "/hello" + }]] + ) + + if code >= 300 then + ngx.status = code + end + ngx.say(body) + } + } +--- request +GET /t +--- error_code: 400 +--- response_body eval +qr/failed to check the configuration of plugin proxy-cache/ +--- no_error_log +[error] + + + +=== TEST 3: sanity check (invalid type for cache_key) +--- config + l
[GitHub] [incubator-apisix] agile6v commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk.
agile6v commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk. URL: https://github.com/apache/incubator-apisix/pull/1153#discussion_r392659815 ## File path: t/plugin/proxy-cache.t ## @@ -0,0 +1,630 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +use t::APISIX 'no_plan'; + +repeat_each(1); +no_long_string(); +no_shuffle(); +no_root_location(); +log_level('info'); + +add_block_preprocessor(sub { +my ($block) = @_; + +my $http_config = $block->http_config // <<_EOC_; + +# for proxy cache +proxy_cache_path /tmp/disk_cache_one levels=1:2 keys_zone=disk_cache_one:50m inactive=1d max_size=1G; +proxy_cache_path /tmp/disk_cache_two levels=1:2 keys_zone=disk_cache_two:50m inactive=1d max_size=1G; + +# for proxy cache +map \$upstream_cache_zone \$upstream_cache_zone_info { +disk_cache_one /tmp/disk_cache_one,1:2; +disk_cache_two /tmp/disk_cache_two,1:2; +} + +server { +listen 1986; +server_tokens off; + +location / { +expires 60s; +return 200 "hello world!"; +} + +location /hello-not-found { +return 404; +} +} +_EOC_ + +$block->set_value("http_config", $http_config); +}); + +run_tests; + +__DATA__ + +=== TEST 1: sanity check (missing required field) +--- config + location /t { + content_by_lua_block { + local t = require("lib.test_admin").test + local code, body = t('/apisix/admin/routes/1', +ngx.HTTP_PUT, +[[{ +"plugins": { +"proxy-cache": { + "cache_bypass": ["$arg_bypass"], + "cache_method": ["GET"], + "cache_http_status": [200], + "hide_cache_headers": true, + "no_cache": ["$arg_no_cache"] +} +}, +"upstream": { +"nodes": { +"127.0.0.1:1980": 1 +}, +"type": "roundrobin" +}, +"uri": "/hello" + }]] + ) + + if code >= 300 then + ngx.status = code + end + ngx.say(body) + } + } +--- request +GET /t +--- error_code: 400 +--- response_body eval +qr/failed to check the configuration of plugin proxy-cache/ +--- no_error_log +[error] + + + +=== TEST 2: sanity check (invalid type for cache_method) +--- config + location /t { + content_by_lua_block { + local t = require("lib.test_admin").test + local code, body = t('/apisix/admin/routes/1', +ngx.HTTP_PUT, +[[{ +"plugins": { +"proxy-cache": { + "cache_zone": "disk_cache_one", + "cache_bypass": ["$arg_bypass"], + "cache_method": "GET", + "cache_http_status": [200], + "hide_cache_headers": true, + "no_cache": ["$arg_no_cache"] +} +}, +"upstream": { +"nodes": { +"127.0.0.1:1980": 1 +}, +"type": "roundrobin" +}, +"uri": "/hello" + }]] + ) + + if code >= 300 then + ngx.status = code + end + ngx.say(body) + } + } +--- request +GET /t +--- error_code: 400 +--- response_body eval +qr/failed to check the configuration of plugin proxy-cache/ +--- no_error_log +[error] + + + +=== TEST 3: sanity check (invalid type for cache_key) +--- config + l
[GitHub] [incubator-apisix] agile6v commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk.
agile6v commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk. URL: https://github.com/apache/incubator-apisix/pull/1153#discussion_r392659145 ## File path: lua/apisix/plugins/proxy-cache.lua ## @@ -0,0 +1,259 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one or more +-- contributor license agreements. See the NOTICE file distributed with +-- this work for additional information regarding copyright ownership. +-- The ASF licenses this file to You under the Apache License, Version 2.0 +-- (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + +local core = require("apisix.core") +local ngx_re = require("ngx.re") +local tab_insert = table.insert +local tab_concat = table.concat +local string = string +local io_open = io.open +local io_close = io.close +local ngx = ngx +local os = os +local ipairs = ipairs +local pairs = pairs +local tonumber = tonumber + +local plugin_name = "proxy-cache" + +local schema = { +type = "object", +properties = { +cache_zone = { +type = "string", +minLength = 1 +}, +cache_key = { +type = "array", +minItems = 1, +items = { +description = "a key for caching", +type = "string", +pattern = [[(^[^\$].+$|^\$[0-9a-zA-Z_]+$)]], +}, +default = {"$host", "$request_uri"} Review comment: Method can be specified by the cache_method. How about the user control this? 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk.
membphis commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk. URL: https://github.com/apache/incubator-apisix/pull/1153#discussion_r392658133 ## File path: t/plugin/proxy-cache.t ## @@ -0,0 +1,630 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +use t::APISIX 'no_plan'; + +repeat_each(1); +no_long_string(); +no_shuffle(); +no_root_location(); +log_level('info'); + +add_block_preprocessor(sub { +my ($block) = @_; + +my $http_config = $block->http_config // <<_EOC_; + +# for proxy cache +proxy_cache_path /tmp/disk_cache_one levels=1:2 keys_zone=disk_cache_one:50m inactive=1d max_size=1G; +proxy_cache_path /tmp/disk_cache_two levels=1:2 keys_zone=disk_cache_two:50m inactive=1d max_size=1G; + +# for proxy cache +map \$upstream_cache_zone \$upstream_cache_zone_info { +disk_cache_one /tmp/disk_cache_one,1:2; +disk_cache_two /tmp/disk_cache_two,1:2; +} + +server { +listen 1986; +server_tokens off; + +location / { +expires 60s; +return 200 "hello world!"; +} + +location /hello-not-found { +return 404; +} +} +_EOC_ + +$block->set_value("http_config", $http_config); +}); + +run_tests; + +__DATA__ + +=== TEST 1: sanity check (missing required field) +--- config + location /t { + content_by_lua_block { + local t = require("lib.test_admin").test + local code, body = t('/apisix/admin/routes/1', +ngx.HTTP_PUT, +[[{ +"plugins": { +"proxy-cache": { + "cache_bypass": ["$arg_bypass"], + "cache_method": ["GET"], + "cache_http_status": [200], + "hide_cache_headers": true, + "no_cache": ["$arg_no_cache"] +} +}, +"upstream": { +"nodes": { +"127.0.0.1:1980": 1 +}, +"type": "roundrobin" +}, +"uri": "/hello" + }]] + ) + + if code >= 300 then + ngx.status = code + end + ngx.say(body) + } + } +--- request +GET /t +--- error_code: 400 +--- response_body eval +qr/failed to check the configuration of plugin proxy-cache/ +--- no_error_log +[error] + + + +=== TEST 2: sanity check (invalid type for cache_method) +--- config + location /t { + content_by_lua_block { + local t = require("lib.test_admin").test + local code, body = t('/apisix/admin/routes/1', +ngx.HTTP_PUT, +[[{ +"plugins": { +"proxy-cache": { + "cache_zone": "disk_cache_one", + "cache_bypass": ["$arg_bypass"], + "cache_method": "GET", + "cache_http_status": [200], + "hide_cache_headers": true, + "no_cache": ["$arg_no_cache"] +} +}, +"upstream": { +"nodes": { +"127.0.0.1:1980": 1 +}, +"type": "roundrobin" +}, +"uri": "/hello" + }]] + ) + + if code >= 300 then + ngx.status = code + end + ngx.say(body) + } + } +--- request +GET /t +--- error_code: 400 +--- response_body eval +qr/failed to check the configuration of plugin proxy-cache/ +--- no_error_log +[error] + + + +=== TEST 3: sanity check (invalid type for cache_key) +--- config +
[GitHub] [incubator-apisix] membphis commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk.
membphis commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk. URL: https://github.com/apache/incubator-apisix/pull/1153#discussion_r392657923 ## File path: lua/apisix/plugins/proxy-cache.lua ## @@ -178,6 +158,91 @@ local function match_method_and_status(conf, ctx) return false end +-- refer to https://gist.github.com/titpetric/ed6ec548af160e82c650cf39074878fb +local function file_exists(name) +local f = io_open(name, "r") +if f~=nil then io_close(f) return true else return false end +end + + +local function explode(d, p) +local t, ll +t={} +ll=0 +if(#p == 1) then return {p} end +while true do +local l=string.find(p, d, ll, true) -- find the next d in the string +if l~=nil then -- if "not not" found then.. +tab_insert(t, string.sub(p, ll, l-1)) -- Save it in our array. +ll=l+1 -- save just after where we found it for searching next time. +else +tab_insert(t, string.sub(p, ll)) -- Save what's left in our array. +break -- Break at end, as it should be, according to the lua manual. +end +end +return t +end + + +local function generate_cache_filename(cache_path, cache_levels, cache_key) +local md5sum = ngx.md5(cache_key) +local levels = explode(":", cache_levels) +local filename = "" + +local index = string.len(md5sum) +for k, v in pairs(levels) do +local length = tonumber(v) +-- add trailing [length] chars to index +index = index - length; +filename = filename .. md5sum:sub(index+1, index+length) .. "/"; +end +if cache_path:sub(-1) ~= "/" then +cache_path = cache_path .. "/"; +end +filename = cache_path .. filename .. md5sum +return filename +end + + +local function cache_purge(conf, ctx) +local cache_zone_info = ngx_re.split(ctx.var.upstream_cache_zone_info, ",") + +local filename = generate_cache_filename(cache_zone_info[1], cache_zone_info[2], + ctx.var.upstream_cache_key) +if file_exists(filename) then +os.remove(filename) Review comment: that is fine. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] membphis commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk.
membphis commented on a change in pull request #1153: feature: support for proxy caching plugin based on disk. URL: https://github.com/apache/incubator-apisix/pull/1153#discussion_r392657840 ## File path: lua/apisix/plugins/proxy-cache.lua ## @@ -0,0 +1,259 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one or more +-- contributor license agreements. See the NOTICE file distributed with +-- this work for additional information regarding copyright ownership. +-- The ASF licenses this file to You under the Apache License, Version 2.0 +-- (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + +local core = require("apisix.core") +local ngx_re = require("ngx.re") +local tab_insert = table.insert +local tab_concat = table.concat +local string = string +local io_open = io.open +local io_close = io.close +local ngx = ngx +local os = os +local ipairs = ipairs +local pairs = pairs +local tonumber = tonumber + +local plugin_name = "proxy-cache" + +local schema = { +type = "object", +properties = { +cache_zone = { +type = "string", +minLength = 1 +}, +cache_key = { +type = "array", +minItems = 1, +items = { +description = "a key for caching", +type = "string", +pattern = [[(^[^\$].+$|^\$[0-9a-zA-Z_]+$)]], +}, +default = {"$host", "$request_uri"} Review comment: `{"$request_method", "$host", "$request_uri"}` I think we need to add `method` 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-apisix] agile6v commented on issue #1153: feature: support for proxy caching plugin based on disk.
agile6v commented on issue #1153: feature: support for proxy caching plugin based on disk. URL: https://github.com/apache/incubator-apisix/pull/1153#issuecomment-599180094 > @agile6v It seems that you have to rebase your branch, this branch has conflicted with master branch. Resolved. 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: us...@infra.apache.org With regards, Apache Git Services