Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

access_by_lua does not seem consistent #1838

Closed
gnois opened this issue Dec 22, 2020 · 1 comment
Closed

access_by_lua does not seem consistent #1838

gnois opened this issue Dec 22, 2020 · 1 comment

Comments

@gnois
Copy link

gnois commented Dec 22, 2020

For the below nginx.conf, path /a, /c and /e gives expected output 403 forbidden.

But for path /b and /d, the first invocation gives 500 internal server error. Invoking the same path again in future gives 404 not found.

nginx.conf

worker_processes 1;
error_log logs/error.log notice;
daemon off;
events {
    worker_connections 1024;
}

http {
    server {
        listen 8888;

        location /a {
           access_by_lua_block {
               return ngx.exit(ngx.HTTP_FORBIDDEN)
           }
        }

        # 500, then 404
        location /b {
           access_by_lua_block {
               require('access')
           }
        }

        location /c {
           access_by_lua "return ngx.exit(ngx.HTTP_FORBIDDEN)";
        }

        # 500, then 404
        location /d {
           access_by_lua "require('access')";
        }

        location /e {
           access_by_lua_file "access.lua";
        }

    }
}

access.lua

return ngx.exit(ngx.HTTP_FORBIDDEN)

Here is the partial error.log after invoking path /b

[error] 9657#100092: *1 lua entry thread aborted: runtime error: attempt to yield across C-call boundary
stack traceback:
coroutine 0:
        [C]: in function 'require'
        access_by_lua(nginx.conf:22):2: in main chunk, client: 192.168.50.96, server: , request: "GET /b HTTP/1.1", host: "192.168.50.124:8888"
[error] 9657#100092: *2 open() "./html/b" failed (2: No such file or directory), client: 192.168.50.96, server: , request: "GET /b HTTP/1.1", host: "192.168.50.124:8888"

OpenResty 1.19.3.1 on Windows and FreeBSD

@LubinLew
Copy link
Contributor

see openresty/lua-resty-redis#3 ,this is a limit of require function

@gnois gnois closed this as completed Dec 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants