标题:[转载]nginx模块(echo,set-misc,simpl-ngx_devel_kit)使用实战 出处:向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除 时间:Wed, 12 Oct 2016 16:50:04 +0000 作者:jackxiang 地址:http://jackxiang.com/post/8998/ 内容: DownLoad:https://github.com/openresty/set-misc-nginx-module/ 最近公司运营提出需求,需要使从公司网站上下载的资料文件显示为中文名称,研发部问道我们有没有好的实现方法,php应该有这样的功能,研发回复说,之前就是这样实现过,但太消耗内存,不做考虑了,才有现在下载资料文件,显示中文名称没有实现。想了想,记起前段时间看agentzh(章亦春)大牛关于nginx的大作以及他写的nginx的模块,似乎有实现此类功能的模块,找了一下果然有:http://wiki.nginx.org/HttpSetMiscModule#Installation 利用其中 set_decode_base64 以及nginx 的 add_header 添加一个http头:Content-Disposition ,配合php代码实现。 nginx 添加模块重新编译 下载需要的模块: 到 https://github.com/agentzh/ 下载模块 agentzh-echo-nginx-module-v0.41-1-gb3ad5c1.tar.gz agentzh-set-misc-nginx-module-v0.22rc8-5-ge79e7f0.tar.gz simpl-ngx_devel_kit-v0.2.17-10-g4192ba6.tar.gz 解压到对应目录 安装: ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --add-module=/usr/local/nginx_module/ngx_devel_kit --add-module=/usr/local/nginx_module/misc-nginx --add-module=/usr/local/nginx_module/echo-nginx make -j2 make install php 实现部分我也不是太懂,就不贴出来了。 nginx 相关配置段 点击在新窗口中浏览此图片 http://jackxiang.com/attachment.php?fid=460 最终效果,上图 点击在新窗口中浏览此图片 http://jackxiang.com/attachment.php?fid=461 各位童鞋注意啦:该种方式在使用CDN的网站中也可以生效的。 从该功能上线以来看,效果还不错,agentzh(章亦春)写的nginx模块那是杠杠的 参考:http://wiki.nginx.org/HttpSetMiscModule#Installation 来自:http://longzhiyi.blog.51cto.com/350171/964677 Generated by Jackxiang's Bo-blog 2.1.1 Release