参考 http://wiki.nginx.org/Phases (2016.3追記)上記のURLは ページがなくなっていました。残念ながらオフィシャルページで似た記載が見当たりません。下記あたりを参照してください。 http://www.aosabook.org/en/nginx.html#sec.nginx.internals http://www.nginxguts.com/2011/01/phases/ http://www.programering.com/a/MzN4MzMwATY.html http://www.slideshare.net/joshzhu/nginx-internals/37 lua-nginx-module がフックする処理 lua-nginx-module は、上記の nginx の Phase のうち、Rewrite, Access, Content,
What's busted, precious? busted is a unit testing framework with a focus on being easy to use. busted works with lua >= 5.1, moonscript, terra, and LuaJIT >= 2.0.0. busted test specs read naturally without being too verbose. You can even chain asserts and negations, such as assert.not.equals. Nest blocks of tests with contextual descriptions using describe, and add tags to blocks so you can run ar
You’ve heard that Redis has an embedded scripting language, but haven’t given it a try yet? Here’s a tour of what you need to understand to use the power of Lua with your Redis server. Hello, Lua! Our first Redis Lua script just returns a value without actually interacting with Redis in any meaningful way: This is as simple as it gets. The first line sets up a local variable with our message, and
出来るだけ拡張しないでやりたいことをやる逆引き。 OpenResty は 1.7.2.1 で試してる。 cookie 用の日付を取得したい ngx.cookie_time(sec) で取得できる 文字列で Mon, 29-Sep-14 14:21:34 GMT こんな感じ 今の時間を秒で取得したい ngx.now() で取得できる A-Za-z0-9 の乱数を生成する デフォルトでは出来ない https://github.com/bungle/lua-resty-random cookie を作る機能 デフォルトでは無い https://github.com/cloudflare/lua-resty-cookie ただ ngx.header 使えば何でも出来る
openresty をいじっていてマニュアルをチラ見してると、時刻周りのAPIの説明にこんなことが書かれている。 ngx.time syntax: secs = ngx.time() context: init_worker_by_lua, set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*, header_filter_by_lua*, body_filter_by_lua*, log_by_lua*, ngx.timer.** Returns the elapsed seconds from the epoch for the current time stamp from the nginx cached time (no syscall involved unlike Lua's date library).
まとめの後に追記を追加。 OpenResty は Nginx をダイナミック・リバースプロキシーサーバに仕立て上げたり、テンプレートエンジンを仕込んでバックエンドの JSON API サーバにリクエストしたレスポンスデータを元にレンダリングして返したり、と色々便利に使えるお気楽ウェブアプリ環境なのだけれど、画像処理系のCPUに負荷のかかりそうなものでもお気軽にいけるのかなとふと疑問に思ったの実験してみる。 OpenResty や LuaRocks のインストールは homebrew でさっくり入るし、windows はパソコン初心者並の知識しかないのではしょる事にして、とりあえずテーマを決める。 「nginx 画像処理」でググってみると「簡単!リアルタイム画像変換をNginxだけで行う方法 | cloudrop」ってのが一番上にあったり「S3をバックエンドにngx_small_lightで
Lua Advent Calendar 2014 7日目の記事です。 wootheeというUA解析プロジェクトを最近知ったのですが、 Lua版が無さそうだったので書いてみました。 本当はLua単体で動くようにしたかったんですが、諸事情によりOpenresty依存となっております。 理由は後述。 ちなみに書いた動機など。 ちょうど、エンドユーザのUA解析してDB登録したりゴニョゴニョ出来たらいいなーと思っていた Nginx+Luaを書き始めているが、がっつりLuaを触っていたわけではないのでライブラリっぽいのも練習がてら書いてみたかった 期待された https://twitter.com/songmu/status/525610905946447872 リポジトリ https://github.com/toritori0318/lua-resty-woothee 使い方 READMEそのまま
インストールLuaはC言語のホストプログラムに組み込まれることを目的に設計されており、高速で動作する debianでは、nginx-extras もしくは lua-nginx-module を使うと Luaのコードを通してNginxを制御可能 root@hostname:/home/shimizu# aptitude install nginx-extras (中略) root@hostname:/home/shimizu# aptitude search nginx | grep ^i i A nginx-common - small, powerful, scalable web/proxy server i nginx-extras - nginx web/proxy server (extended version) root@hostname:/home/shimizu# apt
Nginxは非常に強力なhttpdですが、独自のモジュールを実装しようとするとこれまた非常に敷居が高い印象です。 追記 この記事よりも前に http://openresty.org/#DynamicRoutingBasedOnRedis でほとんど同じ内容のエントリが書かれていました。こちらも参照ください モジュールの開発はむずかしい まず開発用のドキュメントはほとんどありません。必然 既存のモジュールをお手本としますが、コメントも少ないのでソースだけが頼りです。 {ファイル,ネットワーク} I/O を伴う処理では、Nginxのノンブロッキング/イベントドリブンのアーキテクチャにのっとってコールバックを駆使したCで実装する必要があり、LLで育ったゆとり脳では太刀打ちできませんでした lua-nginx-module が代わりになるかも なんらかのNginxモジュールを開発しなければならない
この記事は MySQL Casual Advent Calendar 2013 の 12 日目です。 みんな大好き Nginx + Lua ですが、その Lua から MySQL が叩けるとなると、Nginx だけでウェブアプリケーションが書けちゃうという夢が広がりますね。 難しそうというイメージがあるかもしれませんが、実は OpenResty を使うと、そんな環境が簡単に作れてしまうので、今日はその方法を紹介します。 ngx_openresty のインストール 今回は Ubuntu 12.04 での例ですが、ほとんど同様の手順で CentOS 6.5 でも動くことを確認しています。 *1 $ sudo apt-get -y install gcc make libpcre3-dev libssl-dev perl5 wget $ sudo apt-get -y install libmy
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く