Skip to content

Instantly share code, notes, and snippets.

@LasseRafn
Created August 18, 2015 21:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LasseRafn/84b8a9f398b05ce8cf57 to your computer and use it in GitHub Desktop.
Save LasseRafn/84b8a9f398b05ce8cf57 to your computer and use it in GitHub Desktop.
Example Laravel Nginx config to avoid 404-images to be loaded by routes.
...
location ~* \.(gif|jpg|jpeg|ico|png|svg)$ {
# Do jack shit.
}
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
...
@inctor
Copy link

inctor commented Aug 21, 2015

Jeg bruger det her;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/eloomi.app-error.log error;

    sendfile off;

#    location ~ \.php$ {
#        fastcgi_split_path_info ^(.+\.php)(/.+)$;
#        fastcgi_pass 127.0.0.1:9000;
#        fastcgi_index index.php;
#        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#        include fastcgi_params;
#    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }

    location ~ /\.ht {
        deny all;
    }

Og har ikke oplevet dit issue med ovenstående.

Har 2 locations da jeg nogen gange skifter mellem HHVM og PHP5-FPM til testing. Den ene er altid kommenteret ud som du kan se.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment