I'm trying to create a webhook in nginx that will pass the POST and GET variables through to a bash script. So far, I've got the below working:
location /webhook {
if ($request_method != POST) {
return 405;
}
content_by_lua 'os.execute("/opt/bin/webhook.sh arg1 arg2")';
}
However, I'm not sure how to pass the POST and GET parameters through. I've searched online and the only thing I can find is the use of os.execute without parameters or some detailed use of the request body that assumes the user already understands everything you can do with LUA.
Any guidance on how to do this? Thanks!
You should take a look at ngx.req.get_uri_args and ngx.req.get_post_args.
That said, calling os.execute inside the handler is probably not the best idea, since the handler should be non-blocking.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With