Thrift proxy code contribution

魏俊杰 Junjie Wei weijunjie at
Tue Jul 7 14:45:00 UTC 2020

Hi Maxim Dounin, I'm glad to receive your reply.

The nginx directories are as follow:


Just like supporting tcp proxy, we developed a series of modules to support thrift protocol proxying.

No matter using or compiling, these modules are optional.

Config example:

worker_rlimit_nofile 204800;
worker_processes 1;?
error_log  logs/error.log error;
pid        run/;
thrift {
    access_log logs/access.log;

    server {
        listen 8000;
        server_name counter; # counter is service name in thrift request
        location ping {      # ping is method name in thrift request
            proxy_pass ua;
 ?       }

    upstream ua {

Most of our codes are placed in thrift directory, which consists of 1 core module:

  1.  ngx_thrift_core_module

and other functional modules:

  1.  ngx_thrift_upstream_module

  2.  ngx_thrift_proxy_module
  3.  ngx_thrift_log_module
  4.  ngx_thrift_upstream_check_module:tcp active health check
  5.  ngx_thrift_upstream_keepalive_module
  6.  ngx_http_dynamic_upstream_module : using http request to change nginx upstream endpoint without reload nginx conf
  7.  ngx_thrift_limit_req_module
  8.  ngx_thrift_dynamic_req_module: dispatching request to different upstream accoding to request content

The only things we change in original nginx are:

  1.  build script in auto directory to support compile thrift proxy core framework code into nginx
  2.  macro constance like "#define NGX_LOG_DEBUG_THRIFT 0x800" in ngx_log.h, which is non-logical

Otherwise, we developed a standalone thrift procotol encoder/decoder and we preliminarily plan to publish it independently, which will be imported in nginx as a third party lib.

Do you think out thoughts are feasible? We are really looking forward for suggestions and opinions.

By the way, must out codes support other OS like Windows or other event mechanics like poll, select, kqueue?


Junjie Wei

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx-devel mailing list