nginx.conf 1.6 KB

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