nginx.conf 1.4 KB

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