Quantcast

N00b - "set" directive is not allowed here

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

N00b - "set" directive is not allowed here

Joel Parker
I have a set directive inside an http block which I thought was valid but when I run config -t it says the nginx: [emerg] "set" directive is not allowed here.


http {

    log_format bodylog '$remote_addr - $remote_user [$time_local] '
      '"$request" $status $body_bytes_sent '
      '"$http_referer" "$http_user_agent" $request_time '
      '<"$request_body" >"$resp_body"';

     lua_need_request_body on;

     set $resp_body "";
     body_filter_by_lua '
        local resp_body = ngx.arg[1]
        ngx.ctx.buffered = (ngx.ctx.buffered or "") .. resp_body
        if ngx.arg[2] then
           ngx.var.resp_body = ngx.ctx.buffered
        end
       ';

.....

Joel


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: N00b - "set" directive is not allowed here

Robert Paprocki

Set is allowed is server, location, and if blocks. Not http blocks. 

On Apr 25, 2017, at 12:41, Joel Parker <[hidden email]> wrote:

I have a set directive inside an http block which I thought was valid but when I run config -t it says the nginx: [emerg] "set" directive is not allowed here.


http {

    log_format bodylog '$remote_addr - $remote_user [$time_local] '
      '"$request" $status $body_bytes_sent '
      '"$http_referer" "$http_user_agent" $request_time '
      '<"$request_body" >"$resp_body"';

     lua_need_request_body on;

     set $resp_body "";
     body_filter_by_lua '
        local resp_body = ngx.arg[1]
        ngx.ctx.buffered = (ngx.ctx.buffered or "") .. resp_body
        if ngx.arg[2] then
           ngx.var.resp_body = ngx.ctx.buffered
        end
       ';

.....

Joel

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Loading...