How I can duplicate (or create and send) a request with the nginx web server. I can't use post_action
, because it is a synchronous method. Also, I compiled nginx with Lua support, but if I try to use http.request
with ngx.thread.spawn
or coroutine
, I find the request has been executed synchronously. How do I solve this?
location ~ /(.*)\.jpg {
proxy_pass http://127.0.0.1:6081;
access_by_lua_file '/var/m-system/stats.lua';
}
Lua script (with coroutine
):
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)
ngx.thread.spawn not working, only this code worked:
access_by_lua '
local socket = require "socket"
local conn = socket.tcp()
conn:connect("10.10.1.1", 2015)
conn:send("GET /lua_async HTTP/1.1\\n\\n")
conn:close()
';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With