yapi.conf 2.0 KB

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