2012-12-12 119 views
0

我想使用nginx获取img。我的nginx配置在这里: listen 80; server_name * .test.com;无法使用nginx获取文件

#charset koi8-r; 

    #access_log logs/host.access.log main; 

    location/{ 
      proxy_pass http://test_com; 
    } 
    location ^~ /img { 
     root /data/img; 
    } 

我把test.html的文件到/数据/ IMG dir.But当我请求http://www.test.com/img/test.html,404发生

有什么错我的配置文件?

谢谢:)

回答

1

文件名以服务为root + uri,即/data/img + /img/test.html与你的配置。相反,最有可能的意思是/data/img/test.html。改为:

location /img { 
    root /data; 
} 

有关详细信息,请参阅http://nginx.org/r/root

+0

它的工作原理!谢谢 – Felix