【问题标题】:How to configure an ngnix-location?如何配置 nginx 位置?
【发布时间】:2012-11-07 12:19:48
【问题描述】:

我想要什么:

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

我使用“位置”得到的结果:

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

我做错了什么?

配置-sn-p:

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

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

【问题讨论】:

    标签: configuration nginx location


    【解决方案1】:

    以下应该有效:

    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

    【讨论】:

      猜你喜欢
      • 2014-02-15
      • 2014-01-30
      • 2018-02-08
      • 2011-07-11
      • 1970-01-01
      • 2018-12-15
      • 1970-01-01
      • 2017-03-19
      • 1970-01-01
      相关资源
      最近更新 更多