123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #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("DBHOSTNAME", "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 'CWD/nginx_mruby/db.rb' cache;
- }
- location ~ /queries {
- default_type "application/json";
- mruby_content_handler 'CWD/nginx_mruby/queries.rb' cache;
- }
- location ~ /fotunes {
- default_type "application/html";
- mruby_content_handler 'CWD/nginx_mruby/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;
- #}
- }
- }
|