Skip to content

Instantly share code, notes, and snippets.

@vnykmshr
Created March 12, 2014 14:00
Show Gist options
  • Save vnykmshr/9507480 to your computer and use it in GitHub Desktop.
Save vnykmshr/9507480 to your computer and use it in GitHub Desktop.
Nginx server configuration for Magento
server {
listen 8080;
server_name magento.vnykmshr.com;
root /var/www/magento/releases/current;
index index.html index.php;
access_log /var/log/nginx/magento.access.log;
error_log /var/log/nginx/magento.error.log;
location / {
try_files $uri $uri/ @handler;
expires 30d;
}
location /app/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /var/ { deny all; }
# Uncomment post installation
# location /install.php { deny all; }
location /var/export/ {
auth_basic "Restricted";
auth_basic_user_file htpasswd;
autoindex on;
}
location /. {
return 404;
}
location @handler {
rewrite / /index.php;
}
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}
location ~ \.php$ {
try_files $uri =404;
expires off;
fastcgi_read_timeout 900s;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
rewrite ^/minify/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
rewrite ^/skin/m/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
location /lib/minify/ {
allow all;
}
gzip on;
#gzip_comp_level 9;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain application/xml text/html text/css text/js application/x-javascript;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment