nginx作爲反向代理訪問靜態資源出現404問題


我的xxx.conf配置(win10)

server { 

    listen 80; 
    autoindex off; 
    server_name image.imooc.com; 
    access_log c:/access.log combined; 
    index index.html index.htm index.jsp index.php; 
    #error_page 404 /404.html; 
    if ( $query_string ~* ".*[\;'\<\>].*" ){ 
         return 404; 
    } 


    location ~ /(mmall_fe|mmall_admin_fe)/dist/view/* { 
         deny all; 
    } 
    location / { 
         root X:\xxx\img; 
         add_header Access-Control-Allow-Origin *; 
    } 

}


然後通過cmd的nginx.exe -t    和  nginx.exe -s reload後  可以本地訪問到

Welcome to nginx!

最後訪問靜態圖片時出現404錯誤

解決辦法是在任務管理器裏把nginx後臺全結束了,然後通過cmd的命令行nginx.exe重新激活(我的問題就是這樣)


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章