如何配置nginx-location?

时间:2012-11-19 14:47:34

标签: configuration nginx location

我想要的是什么:

 / => /var/www/
 /measurements /var/meassurements

我使用的是" location":

 / => /var/www/
 /measurements => /var/measurements/measurements

我做错了什么?

配置-片段:

location / {                                                               
    # root   /usr/share/nginx/html;                                        
    root /var/www/;                                        
    index  index.html index.htm;                                           
}                                                                          

location /measurements {                                                         
    root   /var/measurements/;                                                
    autoindex on;                                                          
}     

1 个答案:

答案 0 :(得分:2)

以下内容应该有效:

location / {                                                               
  # root   /usr/share/nginx/html;                                        
  root /var/www/;                                        
  index  index.html index.htm;                                           
}                                                                          

location /measurements/ {                                                         
  root   /var;                                                
  autoindex on;                                                          
}    

原因是路径是以root + $ uri组成的,所以你最终都在寻找/var/measurements/measurements