default 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # ============================================
  2. # V2Ray Multi-Protocol Nginx Configuration
  3. # ============================================
  4. # This file is included by nginx-proxy for all vhosts
  5. # It configures the paths for VLESS-WS, VLESS-gRPC, and VMess-WS
  6. # ============================================
  7. # ============================================
  8. # VLESS WebSocket (Port 1310) - Root Path
  9. # ============================================
  10. location / {
  11. proxy_redirect off;
  12. proxy_pass http://v2ray:1310;
  13. proxy_http_version 1.1;
  14. # WebSocket upgrade headers
  15. proxy_set_header Upgrade $http_upgrade;
  16. proxy_set_header Connection "upgrade";
  17. # Required headers
  18. proxy_set_header Host $host;
  19. proxy_set_header X-Real-IP $remote_addr;
  20. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  21. proxy_set_header X-Forwarded-Proto $scheme;
  22. # Timeouts for long-running connections
  23. proxy_read_timeout 86400s;
  24. proxy_send_timeout 86400s;
  25. # Buffer settings
  26. proxy_buffering off;
  27. }
  28. # ============================================
  29. # VLESS gRPC (Port 1311)
  30. # ============================================
  31. location /grpc {
  32. # Handle CORS preflight
  33. if ($request_method = 'OPTIONS') {
  34. return 200;
  35. }
  36. # gRPC proxy
  37. grpc_pass grpc://v2ray:1311;
  38. grpc_read_timeout 86400s;
  39. grpc_send_timeout 86400s;
  40. # Required headers
  41. grpc_set_header Host $host;
  42. grpc_set_header X-Real-IP $remote_addr;
  43. grpc_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  44. }
  45. # ============================================
  46. # VMess WebSocket (Port 1312)
  47. # ============================================
  48. location /ws {
  49. proxy_redirect off;
  50. proxy_pass http://v2ray:1312;
  51. proxy_http_version 1.1;
  52. # WebSocket upgrade headers
  53. proxy_set_header Upgrade $http_upgrade;
  54. proxy_set_header Connection "upgrade";
  55. # Required 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. # Timeouts for long-running connections
  61. proxy_read_timeout 86400s;
  62. proxy_send_timeout 86400s;
  63. # Buffer settings
  64. proxy_buffering off;
  65. }