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/02/11 11:22:09 UTC

[GitHub] [incubator-apisix] leehomewl opened a new issue #1120: set variable inoperative!!

leehomewl opened a new issue #1120: set variable inoperative!!
URL: https://github.com/apache/incubator-apisix/issues/1120
 
 
   Hi:
       我开发一个插件, 我在 bin/apisix 中加入初始化变量,我发现一个奇怪的问题:
   如果 我设置这个变量为为空的时候
      location / {
              ......
               set $skip '';
               ......
      }
    我可以在插件 /lua/apisix/plugins目录下通过下面的rewrite阶段去修改这个变量, 并且后面的服务可以用到修改后的值。 是正常的
   
   function _M.rewrite(conf, ctx)
       ngx_var.skip = 0
   end
   
   但如果我改成下面的情况, 初始化这个值得时候设置为1 ,此时,我的插件就不其作用了,修改后的值似乎没有生效, 我测试了很多遍, 一直无法解决。  能帮忙确认下是什么原因吗?
   
      location / {
              ......
               set $skip 1 ;
               ......
      }
   
   
   
   

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] leehomewl edited a comment on issue #1120: set variable inoperative!!

Posted by GitBox <gi...@apache.org>.
leehomewl edited a comment on issue #1120: set variable inoperative!!
URL: https://github.com/apache/incubator-apisix/issues/1120#issuecomment-584702524
 
 
   我打算加入  srcache-nginx-module的模块进来, 我在openresty 上 用rewrite_by_lua 就非常正常。
   但是我在 apisix 上使用的 插件的plugins 的rewrite 就无法成功, 每次赋值都好像执行阶段顺序没有对, 有遇到这种类似的情况的吼一下,谢谢
   
   下面是openresty  正常的写法, 都是ok的。
   
   location /test_foo {
   
        set $key $uri$args;
        srcache_fetch GET /memc $key;
        srcache_store PUT /memc $key;
        srcache_store_statuses 200 301 302;
       set $fetch_skip '1';
       set $store_skip '1';
       rewrite_by_lua '
            ngx.var.fetch_skip = 0
            ngx.var.store_skip = 0
       ';
       srcache_fetch_skip $fetch_skip;
       srcache_store_skip $store_skip;
        proxy_pass  http://192.168.12.148:81;
       }
   }
   

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] leehomewl closed issue #1120: set variable inoperative!!

Posted by GitBox <gi...@apache.org>.
leehomewl closed issue #1120: set variable inoperative!!
URL: https://github.com/apache/incubator-apisix/issues/1120
 
 
   

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on issue #1120: set variable inoperative!!

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #1120: set variable inoperative!!
URL: https://github.com/apache/incubator-apisix/issues/1120#issuecomment-584949073
 
 
   The apisix run both ".access" and ".rewrite" in the "access" phase.
   
   https://github.com/apache/incubator-apisix/blob/master/bin/apisix#L334-L336

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] leehomewl edited a comment on issue #1120: set variable inoperative!!

Posted by GitBox <gi...@apache.org>.
leehomewl edited a comment on issue #1120: set variable inoperative!!
URL: https://github.com/apache/incubator-apisix/issues/1120#issuecomment-584702524
 
 
   我打算加入  srcache-nginx-module的模块进来, 我在openresty 上 用rewrite_by_lua 就非常正常。
   但是我在 apisix 上使用的 插件的plugins 的rewrite 就无法成功, 每次赋值都好像执行阶段顺序没有对, 有遇到这种类似的情况的吼一下,谢谢
   
   下面是openresty  正常的写法, 都是ok的。
   
    location /test_foo {
        set $key $uri$args;
        srcache_fetch GET /memc $key;
        srcache_store PUT /memc $key;
        srcache_store_statuses 200 301 302;
       set $fetch_skip '1';
       set $store_skip '1';
   
       rewrite_by_lua '
            ngx.var.fetch_skip = 0
            ngx.var.store_skip = 0
       ';
   
       srcache_fetch_skip $fetch_skip;
       srcache_store_skip $store_skip;
   
        proxy_pass  http://192.168.12.148:81;
       }
   }
   

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] leehomewl commented on issue #1120: set variable inoperative!!

Posted by GitBox <gi...@apache.org>.
leehomewl commented on issue #1120: set variable inoperative!!
URL: https://github.com/apache/incubator-apisix/issues/1120#issuecomment-584702524
 
 
   我打算加入  srcache-nginx-module的模块进来, 我在openresty 上 用rewrite_by_lua 就非常正常。
   但是我在 apisix 上使用的 插件的plugins 的rewrite 就无法成功, 每次赋值都好像执行阶段顺序没有对, 有遇到这种类似的情况的吼一下,谢谢
   
    location /test_foo {
        set $key $uri$args;
        srcache_fetch GET /memc $key;
        srcache_store PUT /memc $key;
        srcache_store_statuses 200 301 302;
   
   
       set $fetch_skip '1';
       set $store_skip '1';
   
       rewrite_by_lua '
            ngx.var.fetch_skip = 0
            ngx.var.store_skip = 0
       ';
   
       srcache_fetch_skip $fetch_skip;
       srcache_store_skip $store_skip;
   
        proxy_pass  http://192.168.12.148:81;
       }
   }
   

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] leehomewl commented on issue #1120: set variable inoperative!!

Posted by GitBox <gi...@apache.org>.
leehomewl commented on issue #1120: set variable inoperative!!
URL: https://github.com/apache/incubator-apisix/issues/1120#issuecomment-584971766
 
 
   > The apisix run both ".access" and ".rewrite" in the "access" phase.
   > 
   > https://github.com/apache/incubator-apisix/blob/master/bin/apisix#L334-L336
   
   好的,明白了,   我的修改是 set_by_lua  和 rewrite_by_lua 2个执行阶段的,所以在access就无效了。 
   谢谢哈。

----------------------------------------------------------------
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


With regards,
Apache Git Services