nginx.conf 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. lua_package_path 'CWD/?.lua;;';
  10. init_by_lua_block {
  11. jit.opt.start("minstitch=10")
  12. require "resty.core"
  13. encode = require("cjson").encode
  14. mysql = require("resty.mysql")
  15. app = require("app")
  16. }
  17. server {
  18. listen 8080;
  19. location /plaintext {
  20. default_type "text/plain";
  21. content_by_lua_block {
  22. ngx.print("Hello, world!")
  23. }
  24. }
  25. location /json {
  26. default_type "application/json";
  27. content_by_lua_block {
  28. ngx.print(encode({message = "Hello, World!"}))
  29. }
  30. }
  31. location /fortunes {
  32. default_type "text/html; charset=UTF-8";
  33. content_by_lua_block {
  34. app.fortunes()
  35. }
  36. }
  37. location /db {
  38. default_type "application/json";
  39. content_by_lua_block {
  40. app.db()
  41. }
  42. }
  43. location / {
  44. default_type "application/json";
  45. content_by_lua_block {
  46. app.queries()
  47. }
  48. }
  49. }
  50. }