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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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_bytes_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:3001;
  32. }
  33. server {
  34. listen 80;
  35. # Accept both localhost and market-data.local for local development
  36. # market-data.local is required for MT5 EA connectivity (MT5 doesn't allow localhost/127.0.0.1)
  37. server_name localhost market-data.local;
  38. # Health check endpoint
  39. location /health {
  40. proxy_pass http://api/health;
  41. proxy_http_version 1.1;
  42. proxy_set_header Host $host;
  43. proxy_set_header X-Real-IP $remote_addr;
  44. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  45. proxy_set_header X-Forwarded-Proto $scheme;
  46. access_log off;
  47. }
  48. # WebSocket support for Socket.io
  49. location /socket.io/ {
  50. proxy_pass http://api;
  51. proxy_http_version 1.1;
  52. # WebSocket upgrade headers
  53. proxy_set_header Upgrade $http_upgrade;
  54. proxy_set_header Connection "upgrade";
  55. # Standard proxy headers
  56. proxy_set_header Host $host;
  57. proxy_set_header X-Real-IP $remote_addr;
  58. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  59. proxy_set_header X-Forwarded-Proto $scheme;
  60. # WebSocket timeouts (Socket.io uses long-lived connections)
  61. proxy_read_timeout 86400s;
  62. proxy_send_timeout 86400s;
  63. proxy_connect_timeout 60s;
  64. # Disable buffering for real-time data
  65. proxy_buffering off;
  66. proxy_cache off;
  67. }
  68. # API endpoints
  69. location /api/ {
  70. proxy_pass http://api;
  71. proxy_http_version 1.1;
  72. proxy_set_header Host $host;
  73. proxy_set_header X-Real-IP $remote_addr;
  74. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  75. proxy_set_header X-Forwarded-Proto $scheme;
  76. # Timeout settings
  77. proxy_connect_timeout 60s;
  78. proxy_send_timeout 60s;
  79. proxy_read_timeout 60s;
  80. # Buffer settings
  81. proxy_buffering on;
  82. proxy_buffer_size 4k;
  83. proxy_buffers 8 4k;
  84. }
  85. # Root endpoint
  86. location / {
  87. proxy_pass http://api;
  88. proxy_http_version 1.1;
  89. proxy_set_header Host $host;
  90. proxy_set_header X-Real-IP $remote_addr;
  91. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  92. proxy_set_header X-Forwarded-Proto $scheme;
  93. }
  94. }
  95. }