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