ffi1 = require("ffi"); ipaddr = ngx.var.remote_addr; if ngx.var.http_addr ~= nil then ipaddr = ngx.var.http_addr end new_http_host = ffi1.string(ipzone.get_ipzone(ipaddr,ngx.var.host,ngx.var.request_uri)); --ngx.say(ipaddr .. ':' .. ngx.var.http_host .. ':' .. ngx.var.request_uri); if ngx.var.server_port ~= '80' then new_location = 'http://' .. new_http_host .. ':' .. ngx.var.server_port .. ngx.var.request_uri; else new_location = 'http://' .. new_http_host .. ngx.var.request_uri; end return ngx.redirect(new_location);