/upyun-resty

UPYUN's open source software for OpenResty development

upyun-resty

UPYUN's open source software for OpenResty development.

Table of Contents

What is UPYUN

What is OpenResty

OpenResty is a full-fledged web platform by integrating the standard Nginx core, LuaJIT, many carefully written Lua libraries, lots of high quality 3rd-party Nginx modules, and most of their external dependencies. It is designed to help developers easily build scalable web applications, web services, and dynamic web gateways.

Tech Talks

201411 Beijing OSC

201511 Beijing OpenResty Con

201608 Guangzhou UPYUN OpenTalk

  • 基于 ngx_lua 的动态服务路由方案 (Slide) - @yejingx

201612 Shenzhen OpenResty Con

  • OpenResty 在云处理服务器集群中的应用 (Slide) - @yejingx

201712 Hangzhou OpenResty Meetup

  • OpenResty TCP 服务代理和动态路由 (Slide) - @huangnauh

  • OpenResty 项目性能优化实践 (Slide) - @tokers

201811 Hangzhou OpenResty Con

  • 又拍云 OpenResty/Nginx 服务优化实践 (Slide) - @tokers

201901 Shenzhen OpenResty x OpenTalk

  • OpenResty 动态流控的几种姿势 (Slide) - @timebug

201903 Beijing OpenResty x OpenTalk

  • OpenResty 在又拍云容器平台中的应用 (Slide) - @yejingx

Projects

Middleware

Project Slardar

Slardar is a HTTP load balancer based on Nginx and lua-nginx-module, by which you can update your upstream list and run lua scripts without reloading Nginx.

Nginx Modules

base64-nginx-module

This module allows for on-the-fly base64 encode. As same as the standard ngx_http_gzip_module.

zstd-nginx-module

Nginx module for the Zstandard compression.

Libraries

checkups

Manage Nginx upstreams in pure ngx_lua.

  • Periodically heartbeat to upstream servers
  • Proactive and passive health check
  • Dynamic upstream update
  • Balance by weighted round-robin or consistent-hash
  • Synchronize with Nginx upstream blocks
  • Try clusters by levels or by keys

httpipe

Lua HTTP client cosocket driver for OpenResty / ngx_lua, interfaces are more flexible.

  • HTTP 1.0/1.1 and HTTPS
  • Flexible interface design
  • Streaming reader and uploads
  • Chunked-encoding request / response body
  • Sets the timeout for read and send operations
  • Limit the maximum response body size
  • Keepalive

redis-ratelimit

This lua library is a request processing rate limit module for ngx_lua. It is used to limit the request processing rate per a defined key between multiple NGINX instances. The limitation is done using the "leaky bucket" method.

sync

This lua-resty library help you to synchronize data(from redis, mysql, memcached and so on) based on the version changes.

It will check the freshness by comparing the version cached by itself(stored in shared memory) and the one from your external suits, data will be updated when the cached one is stale or for the first time.

ctxdump

ngx.ctx is a magic table provided by ngx_lua, it can be used to store per-request Lua context data, however the lifetime is limited to the current location.

See this issue for the details.

This lua-resty library can help you to bypass this limitation, i.e. it stashes and applies the old ngx.ctx for avoiding being destoried after Nginx internal redirect happens.

consul

This Lua library can help OpenResty/ngx_lua users to load config from consul.

load

This Lua library can help OpenResty/ngx_lua users to dynamically load lua files/scripts.

requests

Yet Another HTTP library for OpenResty.

limit-rate

Lua module for limiting request rate for OpenResty/ngx_lua, using the "token bucket" method.

Community Contributions

slice filter and If-Range requests

The semantic of If-Range isn't implemented correctly when using nginx's slice module.

See here for the details.

autoindex module and request body

The autoindex module doesn't discard the request body explicitly,
hence request body will be treated as a pipelined request, and most of time another unexpected response will be sent to client.

See here for the details.

ngx.req.raw_header with single line break

When the header delimiter is \n(rather than \r\n),
ngx.req.raw_header cannot get the complete protocol headers in some case.

See here for the details.

ngx_lua and filter finalize problem

some ngx_lua's APIs(like ngx.flush) don't handle the nginx filter finalize correctly,
thus the Lua VM may raise some exceptions.

See here for the details.

segmentation fault might occur when SSL renegotiation happens

When the SSL/TLS handshake reuses a existing session and the connection upgrades to HTTP/2, segmentation fault might occur when SSL/TLS renegotiation happens.

This problem only happens under the specific Nginx and OpenSSL combinations.

See here for the details.

Work at UPYUN