Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
特定位置的Nginx add头返回404_Nginx_Location_Content Security Policy - Fatal编程技术网

特定位置的Nginx add头返回404

特定位置的Nginx add头返回404,nginx,location,content-security-policy,Nginx,Location,Content Security Policy,我正在尝试将CSP头添加到特定位置,目前我有以下信息: add_header Content-Security-Policy "frame-ancestors www.example.com example.com; object-src www. example.com example.com; script-src www. example.com example.com;"; location /api { add_header Content-Securit

我正在尝试将CSP头添加到特定位置,目前我有以下信息:

add_header Content-Security-Policy "frame-ancestors www.example.com example.com; object-src www. example.com example.com; script-src www. example.com example.com;";

location /api {
    add_header Content-Security-Policy "default-src 'self'; object-src * ;script-src *;";
}

但是请求返回404,我做错了什么?

你能发布整个Nginx文件吗?那里有
if
语句吗?PS:如果您希望Nginx发送标题而不考虑响应代码,请在标题值之后添加
始终
始终添加标题内容安全策略“val”