api.conf 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. set $_level '';
  2. set $_switched '';
  3. set $_url '';
  4. set $_ver '';
  5. set $_ref '';
  6. set $_type '';
  7. set $_mode '';
  8. set $_bodyhash '';
  9. error_page 500 502 504 /error;
  10. location = /error {
  11. internal;
  12. access_log off;
  13. more_set_headers
  14. 'access-control-allow-origin: *'
  15. 'access-control-expose-headers: gateway-err--'
  16. 'gateway-err--: {"msg": "$arg_msg", "addr": "$upstream_addr", "url": "$arg_url"}'
  17. ;
  18. return 204;
  19. }
  20. location = /preflight {
  21. internal;
  22. access_log off;
  23. more_set_headers
  24. 'access-control-allow-origin: *'
  25. 'access-control-allow-methods: GET,POST,PUT,PATCH,TRACE,DELETE,HEAD,OPTIONS'
  26. 'access-control-max-age: 1728000'
  27. ;
  28. return 204;
  29. }
  30. # 该接口已作废
  31. location = /http {
  32. access_log off;
  33. more_set_headers 'access-control-allow-origin: *';
  34. return 200 "该接口已作废,请更新前端脚本";
  35. }
  36. # HTTP(S) Proxy
  37. location /http/ {
  38. # see ./allowed-sites.conf
  39. if ($_origin_id = '') {
  40. rewrite ^ /error?msg=ORIGIN_NOT_ALLOWED;
  41. }
  42. if ($http_x_jsproxy) {
  43. rewrite ^ /error?msg=CIRCULAR_DEPENDENCY;
  44. }
  45. proxy_set_header x-jsproxy 1;
  46. proxy_set_header Connection $http_connection;
  47. if ($http_access_control_request_methods) {
  48. rewrite ^ /preflight;
  49. }
  50. access_by_lua_file ../lua/http-dec-req-hdr.lua;
  51. proxy_cache my_cache;
  52. proxy_pass $_url;
  53. more_set_headers
  54. 'server: $upstream_http_server'
  55. 'content-security-policy'
  56. 'content-security-policy-report-only'
  57. 'x-frame-options'
  58. 'alt-svc'
  59. 'clear-site-data'
  60. ;
  61. header_filter_by_lua_file ../lua/http-enc-res-hdr.lua;
  62. body_filter_by_lua_file ../lua/http-body-hash.lua;
  63. }
  64. # WebSocket Proxy
  65. location = /ws {
  66. access_by_lua_file ../lua/ws-dec-req-hdr.lua;
  67. proxy_set_header Upgrade $http_upgrade;
  68. proxy_set_header Connection $http_connection;
  69. proxy_pass $_url;
  70. }