S
S
smilexcasper2017-09-26 15:42:38
Nginx
smilexcasper, 2017-09-26 15:42:38

Sending a post request to the server gives an error - what's wrong?

I collect everything in the docker.
I send a request to 192.168.1.200:8585/IdentityAccess/test in which jwt-validation.lua is processed using socket.http.

local res, code, response_headers = http.request{
    -- url = "http://192.168.1.200:86/test",
    url = "http://192.168.1.200:8585/IdentityAccess/test2",
    method = "POST",
    headers =
    {
        ["Content-Type"] = "application/x-www-form-urlencoded";
        ["Content-Length"] = #request_body;
    },
    source = ltn12.source.string(request_body),
    sink = ltn12.sink.table(response_body),
}
ngx.say(res)

The answer does not come - it gives a timeout error.
Nginx config:
location /IdentityAccess/test {
            fastcgi_ignore_client_abort on;
            proxy_ignore_client_abort on;
        	rewrite_by_lua_file 'jwt-validation.lua';
            rewrite ^/IdentityAccess^/ /$1 break;
            proxy_pass http://identityaccess/test;
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Host $server_name;
        }
        location /IdentityAccess/test2 {
            fastcgi_ignore_client_abort on;
            proxy_ignore_client_abort on;
            rewrite ^/IdentityAccess^/ /$1 break;
            proxy_pass http://identityaccess/test2;
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Host $server_name;
        }

If you remove http:// from url i.e. leave it like this - 192.168.1.200:8585/IdentityAccess/test2 - gives an error invalid host ''
At the same time, the response comes to exactly the same request by url - 192.168.1.200:86/test and everything is fine.
What's wrong:

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question