• HttpLuaModule——翻译(二)


    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

    未完,待续。。。

  • 相关阅读:
    airpods2连接win10的方法步骤
    JSON学习笔记
    TCP-IP总线与CAN总线优缺点对比
    svn切换目录
    SQLite学习笔记
    python-opencv安装及入门
    python数据可视化
    python-opencv视觉巡线
    python-opencv进阶应用
    QT窗口和部件
  • 原文地址:https://www.cnblogs.com/liqiu/p/3201006.html
Copyright © 2020-2023  润新知