yapi.conf 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. server {
  2. listen 80;
  3. server_name apidoc.test.proginn.com;
  4. set $temp_request_id $http_x_request_id;
  5. if ($temp_request_id = "") {
  6. set $temp_request_id $request_id;
  7. }
  8. location / {
  9. limit_req zone=byip burst=10;
  10. proxy_pass http://10.200.200.202:3000/;
  11. proxy_set_header Host $http_host;
  12. proxy_set_header X-Real-IP $http_x_real_ip;
  13. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  14. # proxy_set_header X-Forwarded-Proto $scheme;
  15. # proxy_set_header X-Scheme $scheme;
  16. proxy_set_header Origin $http_origin;
  17. proxy_http_version 1.1;
  18. proxy_set_header Upgrade $http_upgrade;
  19. proxy_set_header Connection $connection_upgrade;
  20. #=========================CORS nginx配置=============================
  21. if ($http_origin ~* (https?://apidoc\.proginn\.com(:[0-9]+)?)$) {
  22. set $cors "true";
  23. }
  24. if ($request_method = 'OPTIONS') {
  25. set $cors "${cors}options";
  26. }
  27. if ($request_method = 'GET') {
  28. set $cors "${cors}get";
  29. }
  30. if ($request_method = 'POST') {
  31. set $cors "${cors}post";
  32. }
  33. if ($cors = "trueget") {
  34. add_header 'Access-Control-Allow-Origin' "$http_origin";
  35. add_header 'Access-Control-Allow-Credentials' 'true';
  36. }
  37. if ($cors = "truepost") {
  38. add_header 'Access-Control-Allow-Origin' "$http_origin";
  39. add_header 'Access-Control-Allow-Credentials' 'true';
  40. }
  41. if ($cors = "trueoptions") {
  42. add_header 'Access-Control-Allow-Origin' "$http_origin";
  43. # add_header 'Access-Control-Allow-Origin' '*';
  44. add_header 'Access-Control-Allow-Credentials' 'true';
  45. add_header 'Access-Control-Max-Age' 1728000;
  46. add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,Keep-Alive,X-Requested-With,If-Modified-Since,X-CSRF-TOKEN';
  47. add_header 'Content-Length' 0;
  48. add_header 'Content-Type' 'text/plain charset=UTF-8';
  49. # return 204;
  50. return 200;
  51. }
  52. }
  53. }