2016-04-22 13 views
0

Ich habe Ubuntu 14 auf AWS ngnix ist auf eine Website verweisen. Ich habe alles versucht, aber es dient nicht den statischen Bildern. wenn ich versuche, sie zu cachen. Ich habe jede Kombination aus dieser Zeit gemeistert, aber jedes Mal, wenn ich gehe, gibt es keine Dateien.NGINX nicht zwischenspeichern oder statische Dateien speichern

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

Als ich in das Verzeichnis gibt es keine Dateien im Root-Pfad. Irgendwelche Ideen? Hier

+0

Show complete Server Block –

+0

Upstream-Projekt { Server 172.21.2.230; } Server { hören 80; Standort/{ proxy_pass http: // Projekt; } Ort ~ * \. (Css | js | gif | jpe? G | png) $ { läuft ab 16h; } } – Matt

Antwort

0

ist eine offizielle Blocknutzung 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; 
    } 
Verwandte Themen