api.conf 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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"}'
  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-allow-headers: --raw-info,--level,--url,--referer,--cookie,--origin,--ext,--aceh,--ver,--type,--mode,accept,accept-charset,accept-encoding,accept-language,accept-datetime,authorization,cache-control,content-length,content-type,date,if-match,if-modified-since,if-none-match,if-range,if-unmodified-since,max-forwards,pragma,range,te,upgrade,upgrade-insecure-requests,x-requested-with,chrome-proxy,purpose'
  27. 'access-control-max-age: 1728000'
  28. ;
  29. return 204;
  30. }
  31. # HTTP(S) Proxy
  32. location = /http {
  33. # see ./allowed-sites.conf
  34. if ($_origin_id = '') {
  35. rewrite ^ /error?msg=ORIGIN_NOT_ALLOWED;
  36. }
  37. if ($http_x_jsproxy) {
  38. rewrite ^ /error?msg=CIRCULAR_DEPENDENCY;
  39. }
  40. proxy_set_header x-jsproxy 1;
  41. proxy_set_header Connection $http_connection;
  42. if ($http_access_control_request_headers) {
  43. rewrite ^ /preflight;
  44. }
  45. access_by_lua_file ../lua/http-dec-req-hdr.lua;
  46. proxy_cache my_cache;
  47. proxy_pass $_url;
  48. more_set_headers
  49. 'server: $upstream_http_server'
  50. 'content-security-policy'
  51. 'content-security-policy-report-only'
  52. 'x-frame-options'
  53. 'alt-svc'
  54. 'clear-site-data'
  55. ;
  56. header_filter_by_lua_file ../lua/http-enc-res-hdr.lua;
  57. body_filter_by_lua_file ../lua/http-body-hash.lua;
  58. }
  59. # WebSocket Proxy
  60. location = /ws {
  61. access_by_lua_file ../lua/ws-dec-req-hdr.lua;
  62. proxy_set_header Upgrade $http_upgrade;
  63. proxy_set_header Connection $http_connection;
  64. proxy_pass $_url;
  65. }