现在位置 >首页 > ngx_lua
16℃
2012年04月18日 Nginx ⁄ 被围观 27,633 次+
下载服务器时常被人盗链,时间久了导致服务器大量资源浪费,由于服务器使用nginx做为web服务器。nginx的防盗链方法有很多,可以使用现成的防盗链模块nginx-accesskey-2.0.3,编译ningx时添加此模块即可。 由于服务其他业务需要,所以nginx编译了lua模块,所以就想通过lua来实现下载服务器的防盗链功能,这样就可以免去了accesskey模块。原理就是生成经过处理过的下载链接,然后下载服务器在处理这个下载链接,成功则下载,失败则阻止。下面就是详细的配置实例:(其中要编译nginx添加lua模块支持,可参考:http://...
阅读全文

1℃
2011年12月31日 Nginx ⁄ 被围观 17,582 次+
借助 nginx proxy 模块我们可以给 ngx_lua 很方便地实现非阻塞 HTTP 客户端功能,即使用一个被 proxy 模块处理的内部 location 作为 HTTP client stub,然后通过 ngx_lua 中的 location.capture 接口调用它访问外部 URL。当然为了能解析外部域名,还需要指定 nginx 的 resolver 地址以开启 proxy 模块的域名解析功能。 下面就是一个简单的网页编码转换网关的 nginx 配置(需要事先安装 lua-iconv模块): Nginx 配置代码 http    {        ...        # 指定域名解析服务器地址        resolver 127.0.0.1;     ...
阅读全文
当ngx_cache_purge遇到大小写 [原创]已关闭评论
2011年11月24日 Nginx ⁄ 被围观 12,336 次+
最近配置另外一套刚做的系统时遇到了些问题?采用nginx_cache缓存,使用ngx_cache_purge来清除缓存。由于之前的cms系统url全部是小写字母或数字,所以就没有这样的问题,现在的问题是url包含大小写字母,不管用户输入的是大小写字母都可以访问到指定内容,由于ngx_cache缓存是$host$uri$is_args$args做key进行md5后生成的缓存文件名,这样一来大写小写会各缓存一次,而清除缓存的时候是根据读取页面中的链接来清除缓存的,就会遇到某些缓存是清除不掉的。下面举几个例子。比如: 访问地址:http://www.dyx.com/go/...
阅读全文
ngx_lua v0.1.1: access_by_lua and access_by_lua_file landed已关闭评论
2011年03月11日 Nginx ⁄ 被围观 25,782 次+
After the first public release of ngx_lua, I’m proud to annouce the v0.1.1 version, which has introduced the access_by_lua and access_by_lua_file directives: https://github.com/chaoslawful/lua-nginx-module/downloads Now we can code up our own nginx access-phase handlers directly in pure Lua, with all the capabilities with rewrite_by_lua and content_by_lua, like firing up subrequests to other locations, reading/writing nginx variables, changing response headers, inter...
阅读全文