1. 程式人生 > >nginx作為反向代理訪問靜態資源出現404問題

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重新啟用(我的問題就是這樣)