Below you can view sample Nginx configuration for Magento 1 applications.
server {
listen 80 reuseport;
#listen 443 http2 ssl reuseport;
server_name your-magento1-domain.com;;
root /var/www/html;
location = /js/index.php/x.js {
rewrite ^(.*\.php)/ $1 last;
}
location / {
try_files $uri $uri/ @rewrite;
}
location ~ /(app|var|downloader|includes|pkginfo)/ {
deny all;
}
location ~ rss/(order|catalog) { deny all; }
location ~ ^/([^/])+\.(sh|pl|py|lua|inc|swp|phar|php_|log|ini|md|sql|conf|yml|zip|tar|.+gz)$ { deny all; }
location ~ /\.(svn|git|hg|htpasswd|bash|ssh) { deny all; }
location ~ /(tmp|dev/tests/|errors/local.xml|cron\.php) { deny all; }
location ~* /(lib|media|shell|skin)/.*\.php$ { deny all; }
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
access_log off;
add_header ETag "";
}
location ~* \.(swf|eot|ttf|otf|woff|woff2)$ {
expires max;
log_not_found off;
access_log off;
add_header ETag "";
add_header Access-Control-Allow-Origin "example.com, cdn.example.com";
add_header Cache-Control "public"
}
location @rewrite {
rewrite / /index.php;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:${MAGE_ROUTE};
fastcgi_index index.php;
include fastcgi_params;
fastcgi_keep_conn on;
#fastcgi_param MAGE_RUN_CODE $mage_code;
#fastcgi_param MAGE_RUN_TYPE $mage_type;
}
}
Note: This article is based on Magento Community/Open Source version 1.9.