配置如下:
server { listen 9999; server_name 172.16.3.33; location / { if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin $http_origin; add_header 'Access-Control-Allow-Credentials' true; add_header 'Access-Control-Allow-Headers' 'CJCX,cjcx,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Auth-Token'; add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Length' 0; return 204; } proxy_pass http://172.16.3.33:8083; } add_header Access-Control-Allow-Origin $http_origin; add_header Access-Control-Allow-Methods 'GET,POST,OPTIONS,PUT'; add_header Access-Control-Max-Age 1728000; add_header Access-Control-Allow-Credentials 'true'; add_header Access-Control-Expose-Headers 'X-Auth-Token'; add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,X-Auth-Token'; ##### 暂时没有用到,以上配置未解决问题时可放开一试 # proxy_hide_header 'Host'; # proxy_hide_header 'Origin'; # proxy_hide_header 'Referer'; # proxy_hide_header 'Sec-Fetch-Dest'; # proxy_hide_header 'Sec-Fetch-Mode'; # proxy_hide_header 'Sec-Fetch-Site'; # proxy_hide_header 'User-Agent'; }