nginxを使って「エイリアシング」を行う方法は?

nginxを使って「エイリアシング」を行う方法は?

要求を.NEThttp://localhostに変換するlocalhostのデフォルトのnginx設定を使用します/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

ベストアンサー1

おすすめ記事