X
X
x882015-10-09 14:36:20
Nginx
x88, 2015-10-09 14:36:20

How to make an asynchronous GET Request in nginx?

Good day. Can't send asynchronous request to nginx, using post_action blocks the thread, however when trying to call http.request via ngx.thread.spawn or coroutine still doesn't happen asynchronously:

location ~ /(.*)\.jpg {
                proxy_pass http://127.0.0.1:6081;
                access_by_lua_file '/var/m-system/stats.lua';

        }

local http = require "socket.http"
local co = coroutine.create(function()
    http.request("http://10.10.1.1:81/log?action=view")
    end
)
coroutine.resume(co)

An example of a backend script that I'm testing with:
<?php
    sleep(10);
    echo 'hello';

Please help me with a working example.

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