0

nginx を使用して img を取得しようとしています。私のnginx設定はここにあります: listen 80; サーバー名 *.test.com;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

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

test.html ファイルを /data/img dir に配置しましたが、 http://www.test.com/img/test.htmlをリクエストすると、404 が発生しました

私の設定ファイルに何か問題がありますか?

ありがとう:)

4

1 に答える 1

1

提供するファイル名はroot+ uri、つまり設定で/data/img+/img/test.htmlです。ほとんどの場合、/data/img/test.html代わりに意味します。代わりにこれを使用してください:

location /img {
    root /data;
}

詳細については、 http://nginx.org/r/rootを参照してください。

于 2012-12-12T22:36:41.467 に答える