|
@@ -1,12 +1,3 @@
|
|
|
-if ($_origin_id = '') {
|
|
|
- return 403 'ERROR: origin `$http_origin` is not allowed';
|
|
|
-}
|
|
|
-if ($http_x_jsproxy) {
|
|
|
- return 500 'ERROR: circular dependency';
|
|
|
-}
|
|
|
-proxy_set_header x-jsproxy 1;
|
|
|
-proxy_set_header Connection $http_connection;
|
|
|
-
|
|
|
set $_level '';
|
|
|
set $_switched '';
|
|
|
set $_url '';
|
|
@@ -16,6 +7,20 @@ set $_type '';
|
|
|
set $_mode '';
|
|
|
set $_bodyhash '';
|
|
|
|
|
|
+error_page 500 502 504 /error;
|
|
|
+
|
|
|
+location = /error {
|
|
|
+ internal;
|
|
|
+ access_log off;
|
|
|
+ more_set_headers
|
|
|
+ 'access-control-allow-origin: *'
|
|
|
+ 'access-control-expose-headers: gateway-err--'
|
|
|
+ 'gateway-err--: {"msg": "$arg_msg", "addr": "$upstream_addr"}'
|
|
|
+ ;
|
|
|
+ return 200;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
location = /preflight {
|
|
|
internal;
|
|
|
access_log off;
|
|
@@ -31,8 +36,19 @@ location = /preflight {
|
|
|
|
|
|
# HTTP(S) Proxy
|
|
|
location = /http {
|
|
|
+ # see ./allowed-sites.conf
|
|
|
+ if ($_origin_id = '') {
|
|
|
+ rewrite ^ /error?msg=ORIGIN_NOT_ALLOWED;
|
|
|
+ }
|
|
|
+ if ($http_x_jsproxy) {
|
|
|
+ rewrite ^ /error?msg=CIRCULAR_DEPENDENCY;
|
|
|
+ }
|
|
|
+ proxy_set_header x-jsproxy 1;
|
|
|
+ proxy_set_header Connection $http_connection;
|
|
|
+
|
|
|
+
|
|
|
if ($http_access_control_request_headers) {
|
|
|
- rewrite ^ /preflight;
|
|
|
+ rewrite ^ /preflight;
|
|
|
}
|
|
|
|
|
|
access_by_lua_file ../lua/http-dec-req-hdr.lua;
|