api.conf 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. if ($_origin_id = '') {
  2. return 404 'ERROR: origin `$http_origin` is not allowed';
  3. }
  4. if ($http_x_jsproxy) {
  5. return 404 'ERROR: circular dependency';
  6. }
  7. proxy_set_header x-jsproxy 1;
  8. proxy_set_header Connection $http_connection;
  9. set $_url '';
  10. set $_ver '';
  11. set $_ref '';
  12. set $_type '';
  13. set $_mode '';
  14. location = /preflight {
  15. internal;
  16. access_log off;
  17. more_set_headers
  18. 'access-control-allow-origin: *'
  19. 'access-control-allow-methods: GET,POST,PUT,PATCH,TRACE,DELETE,HEAD,OPTIONS'
  20. 'access-control-allow-headers: --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'
  21. 'access-control-max-age: 1728000'
  22. ;
  23. return 204;
  24. }
  25. # HTTP(S) Proxy
  26. location = /http {
  27. if ($http_access_control_request_headers) {
  28. rewrite ^ /preflight;
  29. }
  30. access_by_lua_file ../lua/http-dec-req-hdr.lua;
  31. proxy_cache my_cache;
  32. proxy_pass $_url;
  33. more_set_headers
  34. 'server: $upstream_http_server'
  35. 'content-security-policy'
  36. 'content-security-policy-report-only'
  37. 'x-frame-options'
  38. ;
  39. header_filter_by_lua_file ../lua/http-enc-res-hdr.lua;
  40. }
  41. # WebSocket Proxy
  42. location = /ws {
  43. access_by_lua_file ../lua/ws-dec-req-hdr.lua;
  44. proxy_pass $_url;
  45. }
  46. location = /traff {
  47. access_log off;
  48. content_by_lua_block {
  49. ngx.say(ngx.shared.traff:get('stat'))
  50. }
  51. more_set_headers
  52. 'access-control-allow-origin: *'
  53. 'cache-control: no-cache'
  54. ;
  55. }