このモジュールを簡単なキャッシュを実施するために使うことができます。近い将来にこのモジュールを拡張する計画があります。Latest version available at http://people.FreeBSD.org/~osa/ngx_http_redis-0.3.8.tar.gz.
Starting from nginx 1.9.11, it’s possible to compile this module as a dynamic module, by using the --add-dynamic-module=PATH
option instead of --add-module=PATH
on the ./configure
command line. Then it’s possible to explicitly load the module in a nginx.conf
via the load_module
(http://nginx.org/en/docs/ngx_core_module.html#load_module)
directive:
load_module /path/to/modules/ngx_http_redis_module.so;
設定例
server {
location / {
set $redis_key $uri;
redis_pass name:6379;
default_type text/html;
error_page 404 = /fallback;
}
location = /fallback {
proxy_pass backend;
}
}
構文: | redis_pass [name:port] |
---|---|
デフォルト: | none |
コンテキスト: | http, server, location |
バックエンドはredis内にデータを設定しなければなりません。redis キーは /uri?args
です。
構文: | redis_bind [addr] |
---|---|
デフォルト: | none |
コンテキスト: | http, server, localtion |
以下のIPアドレスをredis接続のソースアドレスとして使用します。
構文: | redis_connect_timeout [time] |
---|---|
デフォルト: | 60000 |
コンテキスト: | http, server, location |
redisへの接続のタイムアウトのミリ秒。
構文: | redis_read_timeout [time] |
---|---|
デフォルト: | 60000 |
コンテキスト: | http, server, location |
redisからの読み込みのタイムアウトのミリ秒。
構文: | redis_send_timeout [time] |
---|---|
デフォルト: | 60000 |
コンテキスト: | http, server, location |
redisへの送信のタイムアウトのミリ秒。
構文: | redis_buffer_size [size] |
---|---|
デフォルト: | see getpagesize(2) |
コンテキスト: | http, server, location |
recv/sendバッファサイズのバイト数。
構文: | redis_next_upstream [error] [timeout] [invalid_response] [not_found] [off] |
---|---|
デフォルト: | error timeout |
コンテキスト: | http, server, location |
どの失敗条件が他のupstreamサーバへの転送へのリクエストを発生させるべきか?redis_pass 内の値が2つ以上のサーバとのupstreamの場合のみ適用されます。
構文: | redis_gzip_flag [number] |
---|---|
デフォルト: | unset |
コンテキスト: | 場所 |
memcached_gzip_flagの再実装。詳細はhttp://forum.nginx.org/read.php?29,34332,34463 を見てください。
redisキーの値。
redisデータベースの数(0.3.4未満の場合に必須)・
ngx_http_redis >= 0.3.4 では義務ではありません。定義されていない場合のデフォルトの値は0
です。
0.3.5では、keep-alive接続のサポートがNGINX 1.1.4のオリジナルの ngx_http_memcached モジュールからバックポートされました。以前のNGINXのバージョンでは、以下の説明を使う必要があります。
backendのredisサーバへのkeep-alive TCP接続のために、このモジュールと一緒にMaxim Douninのサードパーティ ngx_upstream_keepaliveモジュールを必要とします。
以下は例の設定です:
http {
upstream redisbackend {
server 127.0.0.1:6379;
# a pool with at most 1024 connections
# and do not distinguish the servers:
keepalive 1024 single;
}
server {
...
location /redis {
...
redis_pass redisbackend;
}
}
}
バグレポート、パッチおよび修正の提出には、著者のメールアドレスを使ってください。
Sergey A. Osokin <osa@FreeBSD.ORG.ru>
参照