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