From dfdd1795f54be5b015f2ae82e1982b0bcec568b8 Mon Sep 17 00:00:00 2001 From: moicen Date: Thu, 20 Jan 2022 20:48:00 +0800 Subject: [PATCH] update cross origin config --- conf/admin.conf | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/conf/admin.conf b/conf/admin.conf index 7fe6eb5..0578ebc 100644 --- a/conf/admin.conf +++ b/conf/admin.conf @@ -28,6 +28,18 @@ server { root $resty_loc/nginx/html/admin; index index.html; + if ($http_origin !~ [a-z]+\.moicen\.com$) { + return 403; + } + add_header Access-Control-Allow-Origin $http_origin; + add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS'; + add_header Access-Control-Allow-Headers 'Authorization,unionid,HtySudoerToken,HtyHost,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; + add_header Access-Control-Allow-Credentials true; + add_header Access-Control-Max-Age 86400; + if ($request_method = 'OPTIONS') { + return 200; + } + #Upload image files location /api/ngx/image/upload { content_by_lua_file $resty_loc/resty_funcs/upload.lua; @@ -47,16 +59,10 @@ server { location /api/v1/ws/ { proxy_pass http://127.0.0.1:3001/api/v1/ws/; - proxy_set_header Host $host; } location /api/v1/uc/ { proxy_pass http://127.0.0.1:3000/api/v1/uc/; - proxy_set_header Host $host; } -# location /api/v1/ts/ { -# proxy_pass http://127.0.0.1:8080/api/v1/ts/; -# proxy_set_header Host $host; -# } } server {