nginx.conf 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. worker_processes auto;
  2. worker_cpu_affinity auto;
  3. pid /tmp/nginx.pid;
  4. error_log stderr error;
  5. worker_rlimit_nofile 102400;
  6. timer_resolution 1000ms;
  7. daemon off;
  8. events {
  9. worker_connections 100000;
  10. }
  11. http {
  12. resolver 127.0.0.1;
  13. access_log off;
  14. server_tokens off;
  15. msie_padding off;
  16. sendfile off; #default
  17. tcp_nopush off; #default
  18. tcp_nodelay on; #default
  19. keepalive_timeout 65;
  20. keepalive_disable none;
  21. keepalive_requests 100000;
  22. lua_package_path '/openresty/?.lua;;';
  23. init_by_lua_block {
  24. jit.opt.start("minstitch=10")
  25. require "resty.core"
  26. encode = require("cjson").encode
  27. mysql = require("resty.mysql")
  28. app = require("app")
  29. }
  30. server {
  31. listen 8080 backlog=65535 reuseport;
  32. location /plaintext {
  33. default_type "text/plain";
  34. content_by_lua_block {
  35. ngx.print("Hello, world!")
  36. }
  37. }
  38. location /json {
  39. default_type "application/json";
  40. content_by_lua_block {
  41. ngx.print(encode({message = "Hello, World!"}))
  42. }
  43. }
  44. location /fortunes {
  45. default_type "text/html; charset=UTF-8";
  46. content_by_lua_block {
  47. app.fortunes()
  48. }
  49. }
  50. location /db {
  51. default_type "application/json";
  52. content_by_lua_block {
  53. app.db()
  54. }
  55. }
  56. location / {
  57. default_type "application/json";
  58. content_by_lua_block {
  59. app.queries()
  60. }
  61. }
  62. }
  63. }