Giter Site home page Giter Site logo

Comments (9)

zqzjz0911 avatar zqzjz0911 commented on May 30, 2024

这个没有 其他 代替 方案么? openresty 使用了 nginx 本身的导出函数去实现自己的功能,但与linux不同, 在windows 上所有的 函数都是默认不可见的,所以就没办法调用 ngx_http_lua_ffi_var_get 了。
这里估计要不止一两个 函数 的问题。需要清算一下 resty 里边一共使用了多少函数,我们一次把他们都做导出,估计需要更多的时间去完成,感谢您的建议,我们会尽快完成这部分功能。

from nginx-openresty-windows.

pinghe avatar pinghe commented on May 30, 2024

能否先将下面代码涉及到的先处理了。谢谢

local container_url = ngx.var.container_url
local host = ngx.var.host

-- Check if key exists in local cache
local cache = ngx.shared.ceryx
local res, flags = cache:get(host)
if res then
    ngx.var.container_url = res
    return
end

local redis = require "resty.redis"
local red = redis:new()
red:set_timeout(100) -- 100 ms
local redis_host = os.getenv("CERYX_REDIS_HOST")
if not redis_host then redis_host = "127.0.0.1" end
local redis_port = os.getenv("CERYX_REDIS_PORT")
if not redis_port then redis_port = 6379 end
local res, err = red:connect(redis_host, redis_port)

-- Return if could not connect to Redis
if not res then
    return
end

-- Construct Redis key
local prefix = os.getenv("CERYX_REDIS_PREFIX")
if not prefix then prefix = "ceryx" end
local key = prefix .. ":routes:" .. host

-- Try to get target for host
res, err = red:get(key)
if not res or res == ngx.null then
    -- Construct Redis key for $wildcard
    key = prefix .. ":routes:$wildcard"
    res, err = red:get(key)
    if not res or res == ngx.null then
        return
    end
    ngx.var.container_url = res
    return
end

-- Save found key to local cache for 5 seconds
cache:set(host, res, 5)

ngx.var.container_url = res

from nginx-openresty-windows.

zqzjz0911 avatar zqzjz0911 commented on May 30, 2024

我先看看,我目前只能出一个一揽子解决方案,具体的细节估计还没办法细看。抱歉哈。

from nginx-openresty-windows.

BloodyKnight avatar BloodyKnight commented on May 30, 2024

请问为什么ngx.var.xxxx为何调用了resty/core/var的代码呢,这个是ngx_lua package ngx自带的API,也就是说在C代码里面实现了的,请问您的配置是怎样的。

from nginx-openresty-windows.

BloodyKnight avatar BloodyKnight commented on May 30, 2024

Hi,@pinghe 能留个联系方式么?

from nginx-openresty-windows.

BloodyKnight avatar BloodyKnight commented on May 30, 2024

@pinghe 现在nginx.exe共导出resty所需的全部函数,因此该问题已经修复,请验证。
THANKS

from nginx-openresty-windows.

pinghe avatar pinghe commented on May 30, 2024

多谢,今天在飞机上,没能及时回复。已验证了Openresty_For_Windows_1.9.4.1002_64Bit版本,问题已解决。

此外,在nginx.conf 中如果是

include ../sites-enabled/*;

会报错

2015/09/15 21:43:50 [error] 10808#11256: ReadFile() "D:\temp\openresty\nginx1.9.4/conf/../sites-enabled/.." failed (1: Incorrect function)

如果明确指明了文件名,则不会报错

include ../sites-enabled/ceryx.conf;

在1.9.3.1001 1.7.10.2 都有这个问题。openresty版本在linux环境下没有问题。

from nginx-openresty-windows.

BloodyKnight avatar BloodyKnight commented on May 30, 2024

@pinghe 您好,看错误日志应该是使用Windows的FindNextFile遍历文件夹的时候遍历到.这个目录了,也就是本目录,建议使用_.conf来代替_或者_._,这个问题我明天回公司查一下代码,看看能否修正。
THANKS

from nginx-openresty-windows.

BloodyKnight avatar BloodyKnight commented on May 30, 2024

@pinghe 不好意思看到星号没有显示出来,建议使用星号点conf来代替星号,应该是可以的。

from nginx-openresty-windows.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.