Hi,
How do I get the IP of the client in a :run module?
in php I would do this;
$ip = $_SERVER[‘HTTP_X_REAL_IP’];
 
      
    Hi,
How do I get the IP of the client in a :run module?
in php I would do this;
$ip = $_SERVER[‘HTTP_X_REAL_IP’];
No idea if this is the right way to do it, but I made a little change to coronium.lua file;
      local logstr = dt .. printResult       app.io.writeLine( cloudlog, logstr )     end     --START     app.clientIP = function()       return ngx.var.remote\_addr     end     --END     --Get incoming request data (JSON)     app.input = function()       ngx.req.read\_body()
in the lua code, i call;
local ip = coronium.clientIP()Hi,
That can work, though I recommend you call that in your actual cloud file. That way you don’t lose any adjustments you made in case of fixes.
In the cloud code just do the same:
[lua]
local ip = ngx.var.remote_addr
…
[/lua]
No idea if this is the right way to do it, but I made a little change to coronium.lua file;
      local logstr = dt .. printResult       app.io.writeLine( cloudlog, logstr )     end     --START     app.clientIP = function()       return ngx.var.remote\_addr     end     --END     --Get incoming request data (JSON)     app.input = function()       ngx.req.read\_body()
in the lua code, i call;
local ip = coronium.clientIP()Hi,
That can work, though I recommend you call that in your actual cloud file. That way you don’t lose any adjustments you made in case of fixes.
In the cloud code just do the same:
[lua]
local ip = ngx.var.remote_addr
…
[/lua]