Welcome! Log In Create A New Profile

Advanced

Re: Parse JSON POST request into nginx variable

Robert Paprocki
June 14, 2014 10:00PM
There is a form input module you can use to parse POST body into a variable:

https://github.com/calio/form-input-nginx-module

However this will not get JSON data. For this you make want to look into
leveraging the nxin Lua module in conjunction with the Lua cjson module:

http://wiki.nginx.org/HttpLuaModule
http://www.kyne.com.au/~mark/software/lua-cjson.php

The openresty package combines the above two modules into one package :)

On 06/14/2014 06:48 PM, justink101 wrote:
> How can I read a POST request body which is JSON and get a property? I need
> to read a property and use it as a variable in proxy_pass.
>
> Pseudo code:
>
> $post_request_body = '{"account": "test.mydomain.com", "more-stuff":
> "here"}';
> // I want to get
> $account = "test.mydomain.com";
> proxy_pass $account/rest/of/url/here;
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?2,250864,250864#msg-250864
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Parse JSON POST request into nginx variable

justink101 June 14, 2014 09:48PM

Re: Parse JSON POST request into nginx variable

Robert Paprocki June 14, 2014 10:00PM

Re: Parse JSON POST request into nginx variable

datanasov March 27, 2015 04:21AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 242
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready