nginx.conf 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. user www-data;
  2. worker_processes auto;
  3. error_log stderr error;
  4. #worker_rlimit_nofile 100000;
  5. #timer_resolution 1000ms;
  6. daemon off;
  7. events {
  8. worker_connections 65536;
  9. multi_accept off;
  10. }
  11. http {
  12. include /etc/nginx/mime.types;
  13. access_log off;
  14. server_tokens off;
  15. sendfile off;
  16. tcp_nopush off;
  17. tcp_nodelay on;
  18. keepalive_timeout 65s;
  19. keepalive_disable none;
  20. keepalive_requests 10000;
  21. php_ini_path /deploy/conf/php.ini;
  22. init_worker_by_php '
  23. global $pdo;
  24. $pdo = new PDO("mysql:host=tfb-database;dbname=hello_world", "benchmarkdbuser", "benchmarkdbpass", [
  25. PDO::ATTR_PERSISTENT => true
  26. ]);
  27. require "app.php";
  28. ';
  29. server {
  30. listen 8080 default_server reuseport;
  31. root /;
  32. index index.html;
  33. php_keepalive 100;
  34. location = /hello {
  35. add_header Content-Type text/plain;
  36. content_by_php '
  37. echo "Hello, World!";
  38. ';
  39. }
  40. location = /json {
  41. add_header Content-Type application/json;
  42. content_by_php '
  43. echo json_encode(["message" => "Hello, World!"]);
  44. ';
  45. }
  46. location = /fortune {
  47. add_header Content-Type "text/html; charset=UTF-8";
  48. content_by_php '
  49. fortune();
  50. ';
  51. }
  52. location = /db {
  53. add_header Content-Type application/json;
  54. content_by_php '
  55. db();
  56. ';
  57. }
  58. location /query {
  59. add_header Content-Type application/json;
  60. content_by_php '
  61. $_GET = ngx::query_args();
  62. query();
  63. ';
  64. }
  65. location /update {
  66. add_header Content-Type application/json;
  67. content_by_php '
  68. $_GET = ngx::query_args();
  69. update();
  70. ';
  71. }
  72. # location = /info {
  73. # add_header Content-Type text/html;
  74. # content_by_php '
  75. # phpinfo();
  76. # ';
  77. # }
  78. }
  79. }