2016-04-22 2 views
0

私はAWS上にubuntu 14を持っています。ngnixはウェブサイトを指しています。私はすべてを試しましたが、静的な画像を提供しません。私はそれらをキャッシュしようとするとき。私はこれのすべてのコンボを疲れましたが、私が行くたびにファイルがありません。NGINXが静的ファイルをキャッシュまたは保存していない

location ~* \.(css|js|jpeg|jpg|gif|png|ico|xml)$ { 
    access_log off; 
    expires 30d; 
} 

ルートディレクトリにファイルがありません。何か案は?ここで

+0

ショー完全なサーバーブロック –

+0

上流プロジェクト{ サーバー172.21.2.230です。 } サーバー{ listen 80; 所在地/ { proxy_pass http:// project; } ロケーション〜* \。(css | js | gif | jpe?g | png)$ { は16時間満了します。 } } – Matt

答えて

0

は公式のブロックの使用状況https://www.nginx.com/resources/wiki/start/topics/examples/server_blocks/#

server { 
    # Replace this port with the right one for your requirements 
    listen 80 default_server; #could also be 1.2.3.4:80 

    # Multiple hostnames separated by spaces. Replace these as well. 
    server_name star.yourdomain.com *.yourdomain.com; # Alternately: _ 

    root /PATH/TO/WEBROOT; 

    error_page 404 errors/404.html; 
    access_log logs/star.yourdomain.com.access.log; 

    index index.php index.html index.htm; 

    # static file 404's aren't logged and expires header is set to maximum age 
    location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ { 
    access_log off; 
    expires max; 
    } 

    location ~ \.php$ { 
    include fastcgi_params; 
    fastcgi_intercept_errors on; 
    # By all means use a different server for the fcgi processes if you need to 
    fastcgi_pass 127.0.0.1:YOURFCGIPORTHERE; 
    } 

    location ~ /\.ht { 
    deny all; 
    } 
関連する問題