api.conf 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. location = /preflight {
  13. internal;
  14. more_set_headers
  15. 'access-control-allow-origin: *'
  16. 'access-control-allow-methods: GET,POST,PUT,PATCH,TRACE,DELETE,HEAD,OPTIONS'
  17. 'access-control-allow-headers: --url,--referer,--cookie,--origin,--ext,--aceh,--ver,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'
  18. 'access-control-max-age: 1728000'
  19. ;
  20. return 204;
  21. }
  22. # HTTP(S) Proxy
  23. location = /http {
  24. if ($http_access_control_request_headers) {
  25. rewrite ^ /preflight;
  26. }
  27. access_by_lua_file ../lua/http-dec-req-hdr.lua;
  28. proxy_cache my_cache;
  29. proxy_pass $_url;
  30. more_set_headers
  31. 'server: $upstream_http_server'
  32. 'content-security-policy'
  33. 'content-security-policy-report-only'
  34. 'x-frame-options'
  35. ;
  36. header_filter_by_lua_file ../lua/http-enc-res-hdr.lua;
  37. }
  38. # WebSocket Proxy
  39. location = /ws {
  40. access_by_lua_file ../lua/ws-dec-req-hdr.lua;
  41. proxy_pass $_url;
  42. }
  43. location = /traff {
  44. content_by_lua_block {
  45. ngx.say(ngx.shared.traff:get('stat'))
  46. }
  47. more_set_headers
  48. 'access-control-allow-origin: *'
  49. 'cache-control: no-cache'
  50. ;
  51. }