Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QUESTION: store POST message body to redis #51

Open
vkozubal opened this issue Sep 14, 2017 · 2 comments
Open

QUESTION: store POST message body to redis #51

vkozubal opened this issue Sep 14, 2017 · 2 comments

Comments

@vkozubal
Copy link

vkozubal commented Sep 14, 2017

How can I write the nginx config to store the image to redis

curl -X POST localhost:80/upload/123 --data-binary "@lena.png"

I am trying to use $request_body but it doesn't work as I guess this variable value isn't available in this location.

location ~ /upload/(.*) { redis2_query set $1 $request_body; redis2_pass 172.17.0.4:6379; }
The expected result is to store the image binary data under the 123 key passed as query param.
Is there any way to do that?

UPDATE:
I used the https://github.com/klestoff/read-request-body-nginx-module read_request_body; directive. In this case, I am not able to send image bigger than client_body_buffer_size (default value is 16k) which is bad in if the image is bigger.

@vkozubal vkozubal changed the title QUESTION: store post message body to redis QUESTION: store POST message body to redis Sep 14, 2017
@agentzh
Copy link
Member

agentzh commented Sep 16, 2017

@vkozubal It's possible to do streaming post of large values into redis with a small buffer on the nginx side by using lua-nginx-module's downstream cosocket API and a modified version of lua-resty-redis which does streaming redis set command sending.

@agentzh
Copy link
Member

agentzh commented Sep 16, 2017

@vkozubal But not using this module. This module is hard to make the changes for your requirement. Since redis is a pure memory server, it might not be a good idea in the first place to store really large values into the redis server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants