access_by_lua

access阶段。事例:

location / {
        deny    192.168.1.1;
        allow   192.168.1.0/24;
        allow   10.1.1.0/16;
        deny    all;
 
        access_by_lua '
            local res = ngx.location.capture("/mysql", { ... })
            ...
        ';
 
        # proxy_pass/fastcgi_pass/...
    }

也可以这样实施:

location / {
        access_by_lua '
            local res = ngx.location.capture("/auth")
 
            if res.status == ngx.HTTP_OK then
                return
            end
 
            if res.status == ngx.HTTP_FORBIDDEN then
                ngx.exit(res.status)
            end
 
            ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
        ';
 
        # proxy_pass/fastcgi_pass/postgres_pass/...
    }

英文说明,没翻译过来:Note that when calling ngx.exit(ngx.OK) within a access_by_lua handler, the nginx request processing control flow will still continue to the content handler. To terminate the current request from within a access_by_lua handler, calling ngx.exit with status >= 200 (ngx.HTTP_OK) and status < 300 (ngx.HTTP_SPECIAL_RESPONSE) for successful quits andngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR) (or its friends) for failures.

access_by_lua_file

同上

header_filter_by_lua

未完,待续。。。

相关文章:

  • 2022-12-23
  • 2021-09-20
  • 2021-12-19
  • 2022-02-11
  • 2021-08-27
  • 2022-01-28
  • 2021-08-25
猜你喜欢
  • 2021-07-26
  • 2021-08-06
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2022-01-06
  • 2021-08-28
相关资源
相似解决方案