nginx.conf 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. pid /tmp/nginx.pid;
  2. error_log stderr error;
  3. events {
  4. worker_connections 16384;
  5. multi_accept on;
  6. }
  7. http {
  8. resolver 127.0.0.1;
  9. access_log off;
  10. mruby_init_worker_code 'Userdata.new("my_#{Process.pid}").db = MySQL::Database.new("DBHOSTNAME", "benchmarkdbuser", "benchmarkdbpass", "hello_world")';
  11. mruby_exit_worker_code 'db = Userdata.new("my_#{Process.pid}").db ; db.close if db';
  12. server {
  13. listen 8080;
  14. server_name localhost;
  15. location / {
  16. root html;
  17. index index.html index.htm;
  18. }
  19. location /plaintext {
  20. default_type "text/plain";
  21. mruby_content_handler_code 'Nginx.rputs "Hello, world!"';
  22. }
  23. location /json {
  24. default_type "application/json";
  25. mruby_content_handler_code 'Nginx.rputs JSON::stringify("message" => "Hello, World!")';
  26. }
  27. location ~ /db {
  28. default_type "application/json";
  29. #note: next line has cwd
  30. mruby_content_handler 'CWD/db.rb' cache;
  31. }
  32. location ~ /queries {
  33. default_type "application/json";
  34. #note: next line has cwd
  35. mruby_content_handler 'CWD/queries.rb' cache;
  36. }
  37. # location ~ /fortunes {
  38. # default_type "application/html";
  39. # #note: next line has cwd
  40. # mruby_content_handler 'CWD/fortunes.rb' cache;
  41. # }
  42. }
  43. }