13.
Authentication● Basic認証を行うモジュール ID/PWを固定で簡単に認証を入れたい時は便利 ● Developed by Omega Software Development Group ● https://github.com/omegasdg/libvmod-authentication サンプルコード import authentication; vcl_recv{ if(req.url ~ "^/protected/") { if(!authentication.match("admin", "test")) { error 401 "Authentication Required"; } } } vcl_error{ if (obj.status == 401) { set obj.http.WWW-Authenticate = {"Basic realm="Authorization Required""}; synthetic {"Error 401 Unauthorized"}; return(deliver); } }
14.
crashhandler● セグフォを起こしてバックトレースを取得する VMODやインラインCでのデバッグに使う ● Developed by Kristian Lyngstøl ● https://github.com/varnish/libvmod-crashhandler サンプルコード import crashhandler; vcl_recv{ if(req.url ~ "^/crash/") { crashhandler.crash(); } }
15.
cURL● VCL中にHTTPで他リソースを取得する APIを叩いてその結果のような使い方ができるかも ● Developed by Varnish Software ● https://github.com/varnish/libvmod-curl サンプルコード import curl; sub vcl_recv { curl.fetch("http://example.com/test"); if (curl.header("X-Foo") == "bar") { … } curl.free(); }
16.
dClass OpenDDR (decision classification)● UAからデバイス情報を取得する(OpenDDR) ぱっと見た感じディスプレイサイズなども取得可能 ● Developed by Weather Channel ● https://github.com/TheWeatherChannel/dClass サンプルコード import dclass; sub vcl_init { dclass.init_dclass("/some/path/OpenDDR/1.0.0.0/resources"); dclass.init_dclass_p("/some/path/dClass/dtrees/browser.dtree",1); } sub vcl_recv { set req.http.dclass_openddr = dclass.classify(req.http.user-agent); set req.http.dclass_browser = dclass.classify_p(req.http.user-agent,1); if(dclass.get_ifield("displayWidth") > 320){ .... } }
17.
DeviceAtlas Mobile Detection● モバイルデバイスの各種情報を取得 ● Developed by Varnish Software ● Varnishソフトウェアが有償で提供しています ● https://www.varnish-cache.org/vmod/deviceatlas-mobile-detection
18.
Digest● HMAC-sha1などダイジェストやBase64が扱える SHA1などのDigestの出力はHEXエンコードされて いるので注意 ● Developed by Kristian Lyngstøl ● https://github.com/varnish/libvmod-digestサンプルコードimport digest;sub vcl_recv { if (digest.hmac_sha256("key",req.http.x-some-header) != digest.hmac_sha256("key",req.http.x-some-header-signed)) { error 401 "Naughty user!"; }}
19.
example vmod - hello world!● VMODを作るときに参考になります ● Developed by Martin Blix Grydeland ● https://github.com/varnish/libvmod-example サンプルコード import example; sub vcl_deliver { # This sets resp.http.hello to "Hello, World" set resp.http.hello = example.hello("World"); }
20.
Header manipulation● ヘッダーの操作を行うモジュール 主にクッキーの値の追加や削除を行う ● Developed by Kristian Lyngstøl ● https://github.com/varnish/libvmod-header サンプルコード import header; sub vcl_fetch { header.append(beresp.http.Set-Cookie,"foo=bar"); header.remove(beresp.http.Set-Cookie,"dontneedthiscookie"); }
21.
Memcached● Memcacheへ値のset/get/incrなどを行う ● Developed by Aaron Stone ● https://github.com/sodabrew/libvmod-memcached サンプルコード import memcached; sub vcl_deliver { memcached.servers("localhost"); memcached.set("your_counter", "1", 100, 0); memcached.incr("your_counter", 10); set resp.http.count = memcached.incr("your_counter", 1); }
22.
null - Binary data in synthetic● バイナリデータを送信したいときに利用 vcl_errorでインラインCから使うのが一般的 ● Developed by Kristian Lyngstøl ● https://github.com/varnish/libvmod-header サンプルコード import null; sub vcl_error { C{ Vmod_Func_null.synth(sp,"TEST",4); }C return(deliver); }
24.
redirect● Varnishのめんどくさいリダイレクトを簡単にする わ た し で す / ̄\ ● Developed by | ^o^ | \_/ ● https://github.com/xcir/libvmod-redirect サンプルコード import redirect; sub vcl_recv { if (req.http.user-agent ~ "iP(hone|od)") { error(redirect.location(302,"http://www.example.com/iphoneversion/") , "Moved Temporarily"); } }
25.
Redis● Redisにコマンドを送信する ● Developed by ZephirWorks ● https://github.com/zephirworks/libvmod-redis サンプルコード import redis; sub vcl_init{ redis.init_redis("localhost", 6379, 200); } sub vcl_recv { redis.send("LPUSH client " + client.ip); set req.http.x-redis = redis.call("LTRIM client 0 99"); }
26.
Secure download● Nginxやlighttpdにもある特定の時間まで有効な 使い捨てURL機能を実現する ● Developed by Aurelien Guillaume ● https://github.com/footplus/libvmod-secdown サンプルコード import secdown; sub vcl_recv { if (req.url ~ "^/protected/") { set req.url = secdown.check_url(req.url, "h4ckme", "/expired.html", "/error.html") } }
27.
Shield● クライアントの接続を即切断する機能 dDoS攻撃などの対策に使う ● Developed by Martin Blix Grydeland ● https://github.com/varnish/libvmod-shield サンプルコード import shield; sub vcl_recv { if (req.url ~ "i-am-an-attacker") { shield.conn_reset(); } }
28.
std - the standard VMOD● VCL中からログ出力を行うなどの基本的なVMOD VMODのサンプルコード的な役割も ● Developed by Per Buer ● 標準でインストールされます サンプルコード import std; sub vcl_recv { std.log(“hogehoge”); }
29.
URL Code● URLエンコード・デコードを行う ● Developed by Fastly Inc ● https://github.com/fastly/libvmod-urlcode サンプルコード import urlcode; sub vcl_recv { set req.url = "/example?url=" + urlcode.encode("http://" + req.http.host + req.url); }
30.
URL Sort● URLのクエリをソートしてクエリの順番が違うだけ で別のキャッシュにならないように正規化する ● Developed by Fastly Inc ● https://github.com/cyberroadie/varnish-urlsort サンプルコード import urlsort; sub vcl_recv { set req.url =urlsort.sortquery(req.url); }
31.
Variable Support● 文字列・整数・実数が扱える変数を提供する ● Developed by Varnish Software ● https://github.com/varnish/libvmod-var サンプルコード import var; sub vcl_recv { if (req.http.user-agent ~ iP(od|ad|hone) ) { set var.set_int("idevs", var.get_int("i1") + 1 ); } }
Be the first to comment