|
@@ -0,0 +1,72 @@
|
|
|
+#pid /tmp/nginx.pid;
|
|
|
+
|
|
|
+#error_log stderr error;
|
|
|
+
|
|
|
+
|
|
|
+events {
|
|
|
+ worker_connections 16384;
|
|
|
+}
|
|
|
+
|
|
|
+http {
|
|
|
+ resolver 127.0.0.1;
|
|
|
+ #access_log off;
|
|
|
+
|
|
|
+# https://github.com/matsumoto-r/ngx_mruby/wiki/Class-and-Method#nginxrequest-class
|
|
|
+
|
|
|
+ # db connection pool
|
|
|
+ mruby_init_worker_code 'Userdata.new("my_#{Process.pid}").db = MySQL::Database.new("localhost", "root", "", "benchmark")';
|
|
|
+ mruby_exit_worker_code 'db = Userdata.new("my_#{Process.pid}").db ; db.close if db';
|
|
|
+ server {
|
|
|
+ listen 8000;
|
|
|
+ server_name localhost;
|
|
|
+
|
|
|
+ location / {
|
|
|
+ root html;
|
|
|
+ index index.html index.htm;
|
|
|
+ }
|
|
|
+
|
|
|
+ location /plaintext {
|
|
|
+ default_type "text/plain";
|
|
|
+ mruby_content_handler_code 'Nginx.rputs "Hello World!"';
|
|
|
+ }
|
|
|
+
|
|
|
+ location /json {
|
|
|
+ default_type "application/json";
|
|
|
+ mruby_content_handler_code 'Nginx.rputs JSON::stringify("message" => "Hello World!")';
|
|
|
+ }
|
|
|
+
|
|
|
+ location ~ /db {
|
|
|
+ default_type "application/json";
|
|
|
+ mruby_content_handler '/usr/local/nginx-1.4.7mruby/html/db.rb' cache;
|
|
|
+ }
|
|
|
+
|
|
|
+ location ~ /queries {
|
|
|
+ default_type "application/json";
|
|
|
+ mruby_content_handler '/usr/local/nginx-1.4.7mruby/html/queries.rb' cache;
|
|
|
+ }
|
|
|
+
|
|
|
+ location ~ /fotunes {
|
|
|
+ default_type "application/html";
|
|
|
+ mruby_content_handler '/usr/local/nginx-1.4.7mruby/html/fotunes.rb' cache;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ #location ~ \.rb$ {
|
|
|
+ # default_type "application/json";
|
|
|
+ # mruby_add_handler on;
|
|
|
+ #}
|
|
|
+
|
|
|
+ #error_page 404 /404.html;
|
|
|
+ error_page 500 502 503 504 /50x.html;
|
|
|
+ location = /50x.html {
|
|
|
+ root html;
|
|
|
+ }
|
|
|
+
|
|
|
+ # proxy the PHP scripts to Apache listening on 127.0.0.1:80
|
|
|
+ #
|
|
|
+ #location ~ \.php$ {
|
|
|
+ # proxy_pass http://127.0.0.1;
|
|
|
+ #}
|
|
|
+ }
|
|
|
+}
|