我想在 nginx 單元級別處理 cors,但我不知道它是如何在 nginx 單元上制作的。nginx 配置示例
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, OPTIONS, DELETE, PATCH';
add_header 'Access-Control-Allow-Headers' 'Authorization,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range';
add_header 'Access-Control-Expose-Headers' 'Gc-Export-Errors';
return 204;
}
我如何為 nginx 單元做到這一點?
uj5u.com熱心網友回復:
目前,Nginx Unit 不支持與add_headerso相同的功能,如果您需要自定義標頭進行204回應,則應使用 application.properties 來完成。配置將如下所示:
{
"match":{
"method": "OPTIONS"
},
"action":{
"proxy": "path/to/app_return_204_with_custom_headers"
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/369689.html
標籤:nginx nginx-unit
