基于 memcached 的 Nginx 令牌模塊

jopen 10年前發布 | 15K 次閱讀 Web服務器 nginx-token

nginx-token 是一個基于 memcached 的 Nginx 令牌模塊。

Install

$ git clone git://github.com/roast/nginx-token.git
$ wget 'http://sysoev.ru/nginx/nginx-0.7.65.tar.gz'
$ tar -xzvf nginx-0.7.65.tar.gz
$ cd nginx-0.0.7.65/
$ ./configure --add-module=/absolute/path/to/the/nginx-token/
$ make
$ make install


Directives

*token*
syntax: token[ on|off ]
default: token off
context: http, server, location
Enables or disables the token module.

*token_server*
syntax: token_server [ name:port ]
default: none
context: http, server, location
The backend of memcached which store the token data. 

*token_len*
syntax: token_len [ size ]
default: see getpagesize(2)
context: http, server, location
The token key's length.

*token_key*
syntax: token_key [ line ]
default: key
context: http, server, location
The token key name from the request, just like $_GET['key'].


Sample Config

server 
{
    listen       80;

    root   /var/www;

    location / 
    {
        token            on;
        token_server     127.0.0.1:11211;
    token_len        12;
        token_key    token;
        index index.html index.htm index.php;
        error_page       404 = /real;
    }

    location /real 
    {
        proxy_pass http://backend;
    }
}

項目主頁:http://www.baiduhome.net/lib/view/home/1387779488062

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!