Skip to content

Instantly share code, notes, and snippets.

@vporoshok
Created November 13, 2015 07:58
Show Gist options
  • Save vporoshok/ee01050e6b091128ac24 to your computer and use it in GitHub Desktop.
Save vporoshok/ee01050e6b091128ac24 to your computer and use it in GitHub Desktop.
nginx config
server {
listen 80;
server_name {{ hostname }};
access_log /var/log/nginx/{{ project }}.access.log;
error_log /var/log/nginx/{{ project }}.error.log;
client_max_body_size 100m;
keepalive_timeout 180;
{% if target == 'local' %}sendfile off;{% endif %}
root /var/www/{{ folder }};
# No log this files
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Deny hidden files and php scripts directly
location ~ /\. {
deny all;
}
location ~* \.php$ {
deny all;
}
# Serve static
location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|elma3)$ {
access_log off;
log_not_found off;
{% if target == 'product' %}expires max;{% endif %}
# Content disposition for elma3 files for ie that mean that it's a zip
if ($uri ~ "([^/]+)/[^/]+\.elma3$") {
set $fname $1;
add_header Content-Disposition 'attachments; filename="$fname.elma3"';
}
if (!-f $request_filename){
return 404;
}
}
# Default just try to serve files
location / {
{% if target == 'product' %}expires 6h;{% endif %}
try_files $uri /index.php;
}
# Entry point of app
location = /index.php {
fastcgi_split_path_info ^(index\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
}
# Error pages
# error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment