S
S
smilexcasper2017-07-14 21:47:36
Nginx
smilexcasper, 2017-07-14 21:47:36

Unreadable response from res = ngx.location.capture; res.body with unreadable characters. How about?

php returns json data in the response:
{"success":true,"key1":1,"key2":2}
and when I try to display nginx res.body, I get unreadable characters
dUfgg.png
nginx config:

location /IdentityAccess/loginService {
            rewrite ^/IdentityAccess^/ /$1 break;
            proxy_pass http://identityaccess/login;
            proxy_redirect off;
        }

        location /IdentityAccess/login {
        lua_need_request_body on;
        content_by_lua '
        local res = ngx.location.capture("/IdentityAccess/loginService",{ method = ngx.HTTP_POST,body=ngx.var.request_body })
        if res then
        nxg.var.resbody = res.body
        ngx.say("status: ", res.status)
        ngx.say("body:", res.body)
        else
        ngx.say("error")
        end
        ';
        }

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
AntonDrelin, 2017-07-14
@AntonDrelin

Well, judging by the screenshot, the problem is with the encoding. And they directly checked, i.e. just raise with php -S raise and see?

S
smilexcasper, 2017-07-14
@smilexcasper

no, haven't tried it.
but called /IdentityAccess/loginService - and there the response is readable as needed

S
silverjoe, 2017-07-15
@silverjoe


Well, you can put something like server {
...
charset koi8-r; in the nginx config ;
...
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question