nginx.conf 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. pid /tmp/nginx.pid;
  2. error_log stderr error;
  3. daemon off;
  4. events {
  5. worker_connections 16384;
  6. }
  7. http {
  8. resolver 127.0.0.1;
  9. access_log off;
  10. lua_package_path '/openresty/?.lua;;';
  11. init_by_lua_block {
  12. jit.opt.start("minstitch=10")
  13. require "resty.core"
  14. encode = require("cjson").encode
  15. mysql = require("resty.mysql")
  16. app = require("app")
  17. }
  18. server {
  19. listen 8080;
  20. location /plaintext {
  21. default_type "text/plain";
  22. content_by_lua_block {
  23. ngx.print("Hello, world!")
  24. }
  25. }
  26. location /json {
  27. default_type "application/json";
  28. content_by_lua_block {
  29. ngx.print(encode({message = "Hello, World!"}))
  30. }
  31. }
  32. location /fortunes {
  33. default_type "text/html; charset=UTF-8";
  34. content_by_lua_block {
  35. app.fortunes()
  36. }
  37. }
  38. location /db {
  39. default_type "application/json";
  40. content_by_lua_block {
  41. app.db()
  42. }
  43. }
  44. location / {
  45. default_type "application/json";
  46. content_by_lua_block {
  47. app.queries()
  48. }
  49. }
  50. }
  51. }