Openresty和Tengine基於 Nginx 的兩個衍生版本,某種意義上他們都和淘寶有關系,前者是前淘寶工程師agentzh主導開發的,后者是淘寶的一個開源項目;
Openresty的最大特點是引入了ngx_lua模塊,支持使用lua開發插件;
Tengine的特點是融入了因淘寶自身的一些業務帶來的新功能;
Tengine 簡介
tengine官方網站:http://tengine.taobao.org/index_cn.html
在 Nginx官方版本的基礎上增加的一些定制模塊如下:
1、支持動態加載模塊:通過加載so文件實現,不用再重新編譯整個項目了,配置如下:
dso { load ngx_http_lua_module.so; load ngx_http_memcached_module.so; }
2、ngx_proc_daytime_module模塊,這個模塊允許開一個獨立的服務進程,該模塊本身並未實現具體的業務邏輯,而是構建了一個TCP Server框架,等待開發者來實現自己的業務;
3、ngx_http_concat_module模塊,用於合並多個文件的響應;
4、ngx_http_upstream_session_sticky_module模塊,該模塊是一個負載均衡模塊,通過cookie實現客戶端與后端服務器的會話保持, 在一定條件下可以保證同一個客戶端訪問的都是同一個后端服務器。
5、ngx_http_upstream_check_module模塊,用於檢查upstream上游服務器的健康狀況,如下是一個配置的例子:
upstream cluster1 { # simple round-robin server 192.168.0.1:80; server 192.168.0.2:80; check interval=3000 rise=2 fall=5 timeout=1000 type=http; check_http_send "HEAD / HTTP/1.0\r\n\r\n"; check_http_expect_alive http_2xx http_3xx; }
6、trim filter模塊,用於刪除 html,內嵌 javascript 和 css 中的注釋以及重復的空白符,例如:
location / { trim on; trim_js on; trim_css on; }
7、ngx_http_headers_module模塊,支持根據Content-Type來設置過期時間,例如:
expires_by_types 24h text/html; expires_by_types modified +24h text/xml; expires_by_types @15h30m text/xml; expires_by_types 0 text/xml; expires_by_types -1 text/xml; expires_by_types epoch text/xml;
8、ngx_http_limit_req_module模塊,限制訪問
9、擴展了ngx_http_log_module模塊,支持syslog和pipe;