proxy_chuji_ios_server_proxy.1.conf 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. upstream chuji_ios_server_http_1 {
  2. server 137.220.142.147:9503;
  3. }
  4. upstream chuji_ios_server_ws_1 {
  5. server 137.220.142.147:9601;
  6. }
  7. server {
  8. listen 80;
  9. listen [::]:80;
  10. client_max_body_size 20K;
  11. # listen 443 ssl;
  12. # listen [::]:443 ssl;
  13. # ssl_certificate /etc/nginx/ssl/nurftlg.cn/fullchain.cer;
  14. # ssl_certificate_key /etc/nginx/ssl/nurftlg.cn/nurftlg.cn.key;
  15. # ssl_verify_client off;
  16. # ssl_prefer_server_ciphers on;
  17. # ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  18. # ssl_ciphers HIGH:!aNULL:!MD5:ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
  19. # ssl_session_cache shared:SSL:20m;
  20. # ssl_session_tickets off;
  21. server_name pg1-api1.cj163.xyz pg1-api.cj163.xyz pg2-api.cj263.xyz pg3-api.cj777.xyz;
  22. access_log /var/log/nginx/chuji_ios_api.access.log;
  23. error_log /var/log/nginx/chuji_ios_api.error.log;
  24. real_ip_header X-Forwarded-For;
  25. set_real_ip_from 0.0.0.0/0;
  26. # 跨域
  27. set $cors_credentials '';
  28. set $cors_content_type '';
  29. set $cors_content_length '';
  30. if ($http_origin ~ '.+') {
  31. set $cors_credentials 'true';
  32. }
  33. if ($request_method = OPTIONS) {
  34. set $cors_content_type 'text/plain';
  35. set $cors_content_length '0';
  36. }
  37. add_header Access-Control-Allow-Origin $http_origin always;
  38. add_header Access-Control-Allow-Credentials $cors_credentials always;
  39. add_header Access-Control-Allow-Methods $http_access_control_request_method always;
  40. add_header Access-Control-Allow-Headers $http_access_control_request_headers always;
  41. add_header Content-Type $cors_content_type;
  42. add_header Content-Length $cors_content_length;
  43. if ($request_method = OPTIONS) {
  44. return 204;
  45. }
  46. location / {
  47. proxy_set_header Host $host;
  48. proxy_set_header X-Real-IP $remote_addr;
  49. proxy_set_header X-Forwarded-For $remote_addr;
  50. proxy_set_header REMOTE_ADD $remote_addr;
  51. proxy_set_header Upgrade $http_upgrade;
  52. proxy_pass http://chuji_ios_server_http_1; #后端api容器地址
  53. proxy_redirect off;
  54. }
  55. location /ws {
  56. proxy_pass http://chuji_ios_server_ws_1;
  57. proxy_set_header X-Real-IP $remote_addr;
  58. proxy_set_header Host $host;
  59. proxy_set_header X-Forwarded-For $remote_addr;
  60. proxy_http_version 1.1;
  61. proxy_set_header Upgrade $http_upgrade;
  62. proxy_set_header Connection "upgrade";
  63. rewrite /ws/(.*) /$1 break;
  64. proxy_redirect off;
  65. }
  66. }