From 98dc87ba6f49693c0660072713bc30e79f8aa7e3 Mon Sep 17 00:00:00 2001 From: PJ Date: Fri, 17 Dec 2021 15:15:06 +0100 Subject: [PATCH 1/3] Update CORS rules --- docker/nginx/conf.d/include/cors-wildcard | 31 +++++++++++++++++++++++ docker/nginx/conf.d/server/server.api | 14 +--------- 2 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 docker/nginx/conf.d/include/cors-wildcard diff --git a/docker/nginx/conf.d/include/cors-wildcard b/docker/nginx/conf.d/include/cors-wildcard new file mode 100644 index 00000000..cdc5774f --- /dev/null +++ b/docker/nginx/conf.d/include/cors-wildcard @@ -0,0 +1,31 @@ +if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + # + # Om nom nom cookies + # + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + # + # Custom headers and headers various browsers *should* be OK with but aren't + # + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; + # + # Tell client that this pre-flight info is valid for 20 days + # + add_header 'Access-Control-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + add_header 'Content-Length' 0; + return 204; +} +if ($request_method = 'POST') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; +} +if ($request_method = 'GET') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; +} \ No newline at end of file diff --git a/docker/nginx/conf.d/server/server.api b/docker/nginx/conf.d/server/server.api index c6564c1f..6cafa4ca 100644 --- a/docker/nginx/conf.d/server/server.api +++ b/docker/nginx/conf.d/server/server.api @@ -106,19 +106,7 @@ location /health-check { } location /abuse/ { - if ($request_method = 'OPTIONS') { - add_header 'Access-Control-Allow-Origin' 'https://0404guluqu38oaqapku91ed11kbhkge55smh9lhjukmlrj37lfpm8no.siasky.net'; - - add_header 'Access-Control-Allow-Credentials' 'true'; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; - add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; - - # pre-flight info is valid for 20 days - add_header 'Access-Control-Max-Age' 1728000; - add_header 'Content-Type' 'text/plain charset=UTF-8'; - add_header 'Content-Length' 0; - return 204; - } + include /etc/nginx/conf.d/include/cors-wildcard; proxy_pass http://10.10.10.110:4000/; } From 91cd98eaa1b9b3c9c2f537d231d94779d4dee085 Mon Sep 17 00:00:00 2001 From: PJ Date: Fri, 17 Dec 2021 15:20:31 +0100 Subject: [PATCH 2/3] Add newline --- docker/nginx/conf.d/include/cors-wildcard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/nginx/conf.d/include/cors-wildcard b/docker/nginx/conf.d/include/cors-wildcard index cdc5774f..4867b06f 100644 --- a/docker/nginx/conf.d/include/cors-wildcard +++ b/docker/nginx/conf.d/include/cors-wildcard @@ -28,4 +28,4 @@ if ($request_method = 'GET') { add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; -} \ No newline at end of file +} From a78d0cd98cef7b803944220ed84e587d4c164ab7 Mon Sep 17 00:00:00 2001 From: PJ Date: Fri, 17 Dec 2021 16:00:01 +0100 Subject: [PATCH 3/3] Use plain CORS --- docker/nginx/conf.d/include/cors-wildcard | 31 ----------------------- docker/nginx/conf.d/server/server.api | 2 +- 2 files changed, 1 insertion(+), 32 deletions(-) delete mode 100644 docker/nginx/conf.d/include/cors-wildcard diff --git a/docker/nginx/conf.d/include/cors-wildcard b/docker/nginx/conf.d/include/cors-wildcard deleted file mode 100644 index 4867b06f..00000000 --- a/docker/nginx/conf.d/include/cors-wildcard +++ /dev/null @@ -1,31 +0,0 @@ -if ($request_method = 'OPTIONS') { - add_header 'Access-Control-Allow-Origin' '*'; - # - # Om nom nom cookies - # - add_header 'Access-Control-Allow-Credentials' 'true'; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; - # - # Custom headers and headers various browsers *should* be OK with but aren't - # - add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; - # - # Tell client that this pre-flight info is valid for 20 days - # - add_header 'Access-Control-Max-Age' 1728000; - add_header 'Content-Type' 'text/plain charset=UTF-8'; - add_header 'Content-Length' 0; - return 204; -} -if ($request_method = 'POST') { - add_header 'Access-Control-Allow-Origin' '*'; - add_header 'Access-Control-Allow-Credentials' 'true'; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; - add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; -} -if ($request_method = 'GET') { - add_header 'Access-Control-Allow-Origin' '*'; - add_header 'Access-Control-Allow-Credentials' 'true'; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; - add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; -} diff --git a/docker/nginx/conf.d/server/server.api b/docker/nginx/conf.d/server/server.api index 6cafa4ca..c7222683 100644 --- a/docker/nginx/conf.d/server/server.api +++ b/docker/nginx/conf.d/server/server.api @@ -106,7 +106,7 @@ location /health-check { } location /abuse/ { - include /etc/nginx/conf.d/include/cors-wildcard; + include /etc/nginx/conf.d/include/cors; proxy_pass http://10.10.10.110:4000/; }