nginx.conf 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. pid /tmp/nginx.pid;
  2. error_log stderr error;
  3. events {
  4. worker_connections 16384;
  5. }
  6. http {
  7. resolver 127.0.0.1;
  8. access_log off;
  9. mruby_init_worker_code 'Userdata.new("my_#{Process.pid}").db = MySQL::Database.new("DBHOSTNAME", "benchmarkdbuser", "benchmarkdbpass", "hello_world")';
  10. mruby_exit_worker_code 'db = Userdata.new("my_#{Process.pid}").db ; db.close if db';
  11. server {
  12. listen 8080;
  13. server_name localhost;
  14. location / {
  15. root html;
  16. index index.html index.htm;
  17. }
  18. location /plaintext {
  19. default_type "text/plain";
  20. mruby_content_handler_code 'Nginx.rputs "Hello, world!"';
  21. }
  22. location /json {
  23. default_type "application/json";
  24. mruby_content_handler_code 'Nginx.rputs JSON::stringify("message" => "Hello, World!")';
  25. }
  26. location ~ /db {
  27. default_type "application/json";
  28. #note: next line has cwd
  29. mruby_content_handler 'CWD/db.rb' cache;
  30. }
  31. location ~ /queries {
  32. default_type "application/json";
  33. #note: next line has cwd
  34. mruby_content_handler 'CWD/queries.rb' cache;
  35. }
  36. # location ~ /fortunes {
  37. # default_type "application/html";
  38. # #note: next line has cwd
  39. # mruby_content_handler 'CWD/fortunes.rb' cache;
  40. # }
  41. #location ~ \.rb$ {
  42. # default_type "application/json";
  43. # mruby_add_handler on;
  44. #}
  45. #error_page 404 /404.html;
  46. error_page 500 502 503 504 /50x.html;
  47. location = /50x.html {
  48. root html;
  49. }
  50. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  51. #
  52. #location ~ \.php$ {
  53. # proxy_pass http://127.0.0.1;
  54. #}
  55. }
  56. }