All Projects → tokers → Lua Resty Ctxdump

tokers / Lua Resty Ctxdump

Stash and apply the old ngx.ctx for avoiding being destoried after Nginx internal redirect happens.

Programming Languages

lua
6591 projects
perl
6916 projects

Projects that are alternatives of or similar to Lua Resty Ctxdump

Luajit.io
luajit io framework
Stars: ✭ 277 (+691.43%)
Mutual labels:  openresty, nginx
Kong Docs Cn
微服务 Api 网关 Kong 最新文档中文版
Stars: ✭ 371 (+960%)
Mutual labels:  openresty, nginx
Docker Nginx Auto Ssl
Docker image for automatic generation of SSL certs using Let's encrypt and Open Resty
Stars: ✭ 282 (+705.71%)
Mutual labels:  openresty, nginx
Orange
OpenResty/Nginx Gateway for API Monitoring and Management.
Stars: ✭ 2,208 (+6208.57%)
Mutual labels:  openresty, nginx
Openwaf
Web security protection system based on openresty
Stars: ✭ 563 (+1508.57%)
Mutual labels:  openresty, nginx
Lua Resty Redis Connector
Connection utilities for lua-resty-redis
Stars: ✭ 186 (+431.43%)
Mutual labels:  openresty, nginx
Proxygateway
Proxy Gateway基于openresty(nginx lua module)开发,可以作为接口网关(api gateway)使用,整合业务模块接口,微服务治理聚合,通过web配置界面,能够轻松进行代理配置管理,支持负载均衡,服务器状态检测等
Stars: ✭ 335 (+857.14%)
Mutual labels:  openresty, nginx
Upyun Resty
UPYUN's open source software for OpenResty development
Stars: ✭ 150 (+328.57%)
Mutual labels:  openresty, nginx
Iptv
一键安装管理 FFmpeg / nginx / openresty / xray / v2ray / armbian / proxmox / cloudflare partner,workers / ibm cloud foundry 脚本
Stars: ✭ 481 (+1274.29%)
Mutual labels:  openresty, nginx
Micro Auth
A microservice that makes adding authentication with Google and Github to your application easy.
Stars: ✭ 466 (+1231.43%)
Mutual labels:  openresty, nginx
Nginx Admins Handbook
How to improve NGINX performance, security, and other important things.
Stars: ✭ 12,463 (+35508.57%)
Mutual labels:  openresty, nginx
Lua Resty Post
HTTP post utility for openresty
Stars: ✭ 30 (-14.29%)
Mutual labels:  openresty, nginx
Lua Resty Repl
Interactive console (REPL) for Openresty and luajit code
Stars: ✭ 165 (+371.43%)
Mutual labels:  openresty, nginx
Lnmp
LEMP stack/LAMP stack/LNMP stack installation scripts for CentOS/Redhat Debian and Ubuntu
Stars: ✭ 2,488 (+7008.57%)
Mutual labels:  openresty, nginx
Oneinstack
OneinStack - A PHP/JAVA Deployment Tool
Stars: ✭ 1,983 (+5565.71%)
Mutual labels:  openresty, nginx
Apioak
Full Lifecycle Management API Gateway.
Stars: ✭ 335 (+857.14%)
Mutual labels:  openresty, nginx
Lua Resty Auto Ssl
On the fly (and free) SSL registration and renewal inside OpenResty/nginx with Let's Encrypt.
Stars: ✭ 1,786 (+5002.86%)
Mutual labels:  openresty, nginx
Ngx Oauth
OAuth 2.0 proxy for nginx written in Lua.
Stars: ✭ 146 (+317.14%)
Mutual labels:  openresty, nginx
Nginx Openresty Windows
nginx for windows with openresty
Stars: ✭ 404 (+1054.29%)
Mutual labels:  openresty, nginx
Janus Webrtc Gateway Docker
Perfect Docker Image for Media Streaming Expert User ( https://github.com/meetecho/janus-gateway )
Stars: ✭ 582 (+1562.86%)
Mutual labels:  openresty, nginx

Name

lua-resty-ctxdump - stash and apply the ngx.ctx, avoiding being destoried after Nginx internal redirect happens.

Build Status

Table of Contents

Status

Probably production ready in most cases, though not yet proven in the wild. Please check the issues list and let me know if you have any problems / questions.

Synopsis

location /t1 {
    set $ctx_ref "";
    content_by_lua_block {
        local ctxdump = require "resty.ctxdump"
        ngx.ctx = {
            Date = "Wed May  3 15:18:04 CST 2017",
            Site = "unknown"
        }
        ngx.var.ctx_ref = ctxdump.stash_ngx_ctx()
        ngx.exec("/t2")
    }
}

location /t2 {
    internal;
    content_by_lua_block {
        local ctxdump = require "resty.ctxdump"
        ngx.ctx = ctxdump.apply_ngx_ctx(ngx.var.ctx_ref)
        ngx.say("Date: " .. ngx.ctx["Date"] .. " Site: " .. ngx.ctx["Site"])
    }
}

Methods

stash_ngx_ctx

syntax: ref = stash_ngx_ctx()
phase: *init_worker_by_lua*, set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*, header_filter_by_lua*, body_filter_by_lua*, log_by_lua*, ngx.timer.*, balancer_by_lua*

Reference the ngx.ctx, returns an anchor(a new reference maintained by lua-resty-ctxdump).

Note: stash_ngx_ctx and apply_ngx_ctx must be called in pairs, otherwise memory leak will happen! See apply_ngx_ctx.

apply_ngx_ctx

syntax: old_ngx_ctx = apply_ngx_ctx(ref)
phase: *init_worker_by_lua*, set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*, header_filter_by_lua*, body_filter_by_lua*, log_by_lua*, ngx.timer.*, balancer_by_lua*

fetch the old ngx.ctx with the anchor returns from stash_ngx_ctx. After that, the anchor will be out of work.

Note: stash_ngx_ctx and apply_ngx_ctx must be called in pairs, otherwise memory leak will happen! See stash_ngx_ctx.

Author

Alex Zhang(张超) [email protected], @api7.ai.

Copyright and License

The bundle itself is licensed under the 2-clause BSD license.

Copyright (c) 2017-2021, Alex Zhang.

This module is licensed under the terms of the BSD license.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

See Also

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].