NginxHttpAccessKeyModule
Nginx的防盗链模块NginxHttpAccessKeyModule
1 下载
bear@njava:/$wget http://wiki.nginx.org/images/5/51/Nginx-accesskey-2.0.3.tar.gz
2 配置
bear@njava:/$tar -xzvf Nginx-accesskey-2.0.3.tar.gz bear@njava:/$vi ../nginx-accesskey-2.0.3/config USE_MD5=YES USE_SHA1=YES ngx_addon_name=ngx_http_accesskey_module #HTTP_MODULES="$HTTP_MODULES $HTTP_ACCESSKEY_MODULE" HTTP_MODULES="$HTTP_MODULES ngx_http_accesskey_module" NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_accesskey_module.c"
3 重编译nginx
bear@njava:~/nginx-0.8.34# ./configure --conf-path=/etc/nginx/nginx.conf \--error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-http_stub_status_module --with-http_flv_module --with-http_ssl_module --with-http_dav_module --with-http_gzip_static_module --with-mail --with-mail_ssl_module --with-ipv6 --with-http_realip_module --with-http_geoip_module --with-http_xslt_module --with-http_image_filter_module --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --add-module=../gnosek-nginx-upstream-fair-2131c73 --add-module=../nginx-accesskey-2.0.3
4 配置NginxHttpAccessKeyModule
bear@njava:~/nginx-0.8.34$ vi /etc/nginx/sites-available/njava location /test { accesskey on; accesskey_hashmethod md5; accesskey_arg "abc"; accesskey_signature "njavakey$remote_addr"; }
5 重启nginx
6 使用
使用的时候参考代码如下:
function get_acc_url($url){ return $url."?abc=" . md5('njavakey' . $_SERVER['REMOTE_ADDR']); }
7 代码测试
http://www.njava.com/a.php
标签云
.htaccess 301 2010 Android apache cache cacti CSS date ddos discuz django fastcgi freebsd git google http iftop linux macos mysql nginx njava php pr python sed seo snmp ssh ubuntu ubuntu10.04 wordpress xdebug 优化 密码 文件 时区 用户 登录 监控 缓存 网站 脚本 颜色
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.
近期文章
近期评论
文章归档
链接表
QR Code
