Market Data Service is a high-performance financial data API that provides comprehensive Symbol prices of different markets through both RESTful endpoints and real-time WebSocket connections.

nginx.conf 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. # Nginx configuration for development environment
  2. # HTTP only, WebSocket support enabled
  3. user nginx;
  4. worker_processes auto;
  5. error_log /var/log/nginx/error.log warn;
  6. pid /var/run/nginx.pid;
  7. events {
  8. worker_connections 1024;
  9. }
  10. http {
  11. include /etc/nginx/mime.types;
  12. default_type application/octet-stream;
  13. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  14. '$status $body_size_sent "$http_referer" '
  15. '"$http_user_agent" "$http_x_forwarded_for"';
  16. access_log /var/log/nginx/access.log main;
  17. sendfile on;
  18. tcp_nopush on;
  19. tcp_nodelay on;
  20. keepalive_timeout 65;
  21. types_hash_max_size 2048;
  22. client_max_body_size 50M;
  23. # Gzip compression
  24. gzip on;
  25. gzip_vary on;
  26. gzip_proxied any;
  27. gzip_comp_level 6;
  28. gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml+rss;
  29. # Upstream API server
  30. upstream api {
  31. server api:3000;
  32. }
  33. server {
  34. listen 80;
  35. server_name localhost;
  36. # Health check endpoint
  37. location /health {
  38. proxy_pass http://api/health;
  39. proxy_http_version 1.1;
  40. proxy_set_header Host $host;
  41. proxy_set_header X-Real-IP $remote_addr;
  42. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  43. proxy_set_header X-Forwarded-Proto $scheme;
  44. access_log off;
  45. }
  46. # WebSocket support for Socket.io
  47. location /socket.io/ {
  48. proxy_pass http://api;
  49. proxy_http_version 1.1;
  50. # WebSocket upgrade headers
  51. proxy_set_header Upgrade $http_upgrade;
  52. proxy_set_header Connection "upgrade";
  53. # Standard proxy headers
  54. proxy_set_header Host $host;
  55. proxy_set_header X-Real-IP $remote_addr;
  56. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  57. proxy_set_header X-Forwarded-Proto $scheme;
  58. # WebSocket timeouts (Socket.io uses long-lived connections)
  59. proxy_read_timeout 86400s;
  60. proxy_send_timeout 86400s;
  61. proxy_connect_timeout 60s;
  62. # Disable buffering for real-time data
  63. proxy_buffering off;
  64. proxy_cache off;
  65. }
  66. # API endpoints
  67. location /api/ {
  68. proxy_pass http://api;
  69. proxy_http_version 1.1;
  70. proxy_set_header Host $host;
  71. proxy_set_header X-Real-IP $remote_addr;
  72. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  73. proxy_set_header X-Forwarded-Proto $scheme;
  74. # Timeout settings
  75. proxy_connect_timeout 60s;
  76. proxy_send_timeout 60s;
  77. proxy_read_timeout 60s;
  78. # Buffer settings
  79. proxy_buffering on;
  80. proxy_buffer_size 4k;
  81. proxy_buffers 8 4k;
  82. }
  83. # Root endpoint
  84. location / {
  85. proxy_pass http://api;
  86. proxy_http_version 1.1;
  87. proxy_set_header Host $host;
  88. proxy_set_header X-Real-IP $remote_addr;
  89. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  90. proxy_set_header X-Forwarded-Proto $scheme;
  91. }
  92. }
  93. }