How to close connection from openresty

535 views
Skip to first unread message

Alexis Okuwa

unread,
Jan 11, 2016, 6:57:23 AM1/11/16
to openresty-en
I am building some rate limit code in lua. And want at a point to just close the connection i dont want to send any data. no headers. personal i would like to not even send tcp fin just close it on my end of the kernel i was thinking setting ngx.ctx = nil would help but does not.

Alexis Okuwa

unread,
Jan 11, 2016, 7:16:23 AM1/11/16
to openresty-en
This seems to be doing what i am looking for i am not 100% sure from curl i can see it fully closes the connection and does not send headers

Hamish Forbes

unread,
Jan 11, 2016, 9:02:16 AM1/11/16
to openresty-en
ngx.status = 444
return ngx.exit(444)

That should do it.

"The non-standard code 444 closes a connection without sending a response header."

Yichun Zhang (agentzh)

unread,
Jan 11, 2016, 1:07:21 PM1/11/16
to openresty-en
Hello!

On Mon, Jan 11, 2016 at 6:02 AM, Hamish Forbes wrote:
> ngx.status = 444
> return ngx.exit(444)
>
> That should do it.
>

BTW, the assignment ngx.status = 444 is not really needed here for
this particular usage IMHO :)

Regards,
-agentzh
Reply all
Reply to author
Forward
0 new messages