求助,关于 Nginx 需要访问静态资源鉴权的一个配置问题
資深大佬 : Keppel 2
server { listen 14011; server_name localhost;
#charset koi8-r; #access_log logs/host.access.log main; location / { root /; index index.html index.htm; } location /upload { if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS'; 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'; return 204; } auth_request /auth; root /; } location /auth { internal; proxy_set_header Host $host; proxy_pass_request_body off; proxy_set_header Content-Length ""; proxy_pass http://127.0.0.1:14010/auth; } }
====================================================================== 以上是我的配置,因为需要访问静态资源要鉴权,所以需要携带请求头发请求,但是发送 OPTIONS 请求的时候跨域了,加上了网上说的配置还是不行,求助。
大佬有話說 (6)