nginx模块(echo,set-misc,simpl-ngx_devel_kit)使用实战

   最近公司运营提出需求,需要使从公司网站上下载的资料文件显示为中文名称,研发部问道我们有没有好的实现方法,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

解压到对应目录

安装:

  
  
  
  
  1. ./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 
  2.  
  3. make -j2 
  4.  
  5. make install 

php 实现部分我也不是太懂,就不贴出来了。

nginx 相关配置段

最终效果,上图

各位童鞋注意啦:该种方式在使用CDN的网站中也可以生效的。

从该功能上线以来看,效果还不错,agentzh(章亦春)写的nginx模块那是杠杠的

 参考:http://wiki.nginx.org/HttpSetMiscModule#Installation

 

你可能感兴趣的:(nginx模块(echo,set-misc,simpl-ngx_devel_kit)使用实战)