P
peter.gsnm

  • Joined Jun 25, 2014
  • If i use access_by_lua will it not call proxy_pass ?

    On Wednesday, June 25, 2014 10:39:36 PM UTC+5:30, rpaprocki wrote:
    Hi,

    From the Ngxinx Lua API documentation:

    Do not use this directive and other content handler directives in the same location. For example, this directive and the proxy_pass directive should not be used in the same location.

    You should use access_by_lua instead of content_by_lua.

    On 6/25/2014 05:21, Peter G wrote:
    Hi

    Basically i want to do some safety check before doing proxy_pass

    For example, Lets say I want to block all the PUT methods.

    So my code is like this

         location / {

                         content_by_lua '
                                                    --Blah blah
                                                    if my_condition then
                                                       res = ngx.location.capture("/gohere")
                                                       ngx.say(res.body)
                                                       return
                                                ';

                         proxy_pass http://myupstream;
         }


    AS you can see, I want to first check for some condition and go to alternate locataion which handles say errors.  Only in else condition I want to do proxy_pass.

    I am seeing that Irrespective of my condition, IT is always doing proxy_pass :(

    What am i missing here ?
    .

    • Hi

      Basically i want to do some safety check before doing proxy_pass

      For example, Lets say I want to block all the PUT methods.

      So my code is like this

           location / {

                           content_by_lua '
                                                      --Blah blah
                                                      if my_condition then
                                                         res = ngx.location.capture("/gohere")
                                                         ngx.say(res.body)
                                                         return
                                                  ';

                           proxy_pass http://myupstream;
           }


      AS you can see, I want to first check for some condition and go to alternate locataion which handles say errors.  Only in else condition I want to do proxy_pass.

      I am seeing that Irrespective of my condition, IT is always doing proxy_pass :(

      What am i missing here ?