我使用 localhost 的默认 nginx 配置,它将请求转换http://localhost
为/home/velour/www
.这一切都工作正常。
现在我正在尝试将请求转换为http://localhost/movies
目录/home/velour/Videos/
(我希望能够从其他设备通过本地网络观看电影)。到目前为止我已经尝试过这个(我已经成功地使用alias
apache以类似的方式使用)
location /movies/ {
alias /home/velour/Videos/;
}
nginx 配置:
server {
listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
root /home/velour/www;
index index.php index.html index.htm;
autoindex on;
# Make site accessible from http://localhost/
#server_name _;
location / {
try_files $uri $uri/ =404;
}
location /movies/ {
alias /home/velour/Videos/;
}
error_page 404 /404.html;
}
目前正在发生什么?- nginx 返回 301 并将浏览器重定向回
/
.相关输出
/var/log/nginx/error.log
(详细debug
模式):2016/02/06 17:33:27 [debug] 27630#0: *222 http request line: "GET /movies HTTP/1.1" 2016/02/06 17:33:27 [debug] 27630#0: *222 http uri: "/movies" 2016/02/06 17:33:27 [debug] 27630#0: *222 test location: "/" 2016/02/06 17:33:27 [debug] 27630#0: *222 test location: "movies" 2016/02/06 17:33:27 [debug] 27630#0: *222 using configuration "/movies" 2016/02/06 17:33:27 [debug] 27630#0: *222 trying to use dir: "" "/home/velour/Videos" 2016/02/06 17:33:27 [debug] 27630#0: *222 try file uri: "" 2016/02/06 17:33:27 [debug] 27630#0: *222 http filename: "/home/velour/Videos" 2016/02/06 17:33:27 [debug] 27630#0: *222 HTTP/1.1 301 Moved Permanently Server: nginx/1.4.6 (Ubuntu) Date: Sat, 06 Feb 2016 04:33:27 GMT
我想要发生什么?- 每当发出
/home/velour/Videos/
请求时,nginx 都会给出目录的索引列表 。http://localhost/movies