Reputation: 1692
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!
Upvotes: 3
Views: 1941
Reputation: 16753
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.
Upvotes: 2