nginx: [emerg] unknown directive "if($request_method"


nginx: [emerg] unknown directive "if($request_method"

nginx报错

nginx: [emerg] unknown directive "if($request_method" in 
  ...Nginx1.15.11/conf/vhosts/test.com_80.conf:11

nginx配置文件

10  location / {
11    if($request_method = OPTIONS){
12    add_header Access-Control-Allow-Origin "*";     

报错原因

第11行:if 和 ( 缺一个空格 ,如果没有空格他把if($request_uri当成一个指令了,没有这个指令
修改:第11行if后加1个空格

10    location / {
11      if ($request_method = OPTIONS){
12      add_header Access-Control-Allow-Origin "*";     


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM