Skip to content

Commit

Permalink
Merge pull request #224 from magento-dragons/MAGETWO-35517
Browse files Browse the repository at this point in the history
MAGETWO-35517: Optimize nginx.conf
  • Loading branch information
Momotenko,Natalia(nmomotenko) committed Apr 14, 2015
2 parents dc3cb6e + c3e7b1f commit 0c404fe
Showing 1 changed file with 66 additions and 87 deletions.
153 changes: 66 additions & 87 deletions nginx.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -18,126 +18,105 @@
# }


root $MAGE_ROOT;

root $MAGE_ROOT/pub;

index index.php;
autoindex off;
# disable_symlinks on;
charset off;

location /setup/ {
rewrite / /setup/index.php;

location /setup/pub/ {}
location /setup {
root $MAGE_ROOT;

location /setup/index.php {
location ~ ^/setup/index.php {
fastcgi_pass fastcgi_backend;

fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

location / {
root $MAGE_ROOT/pub;

location / {
rewrite / /index.php ;
}

location /static/ {

if ($MAGE_MODE = "production") {
expires max;
}

location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
add_header Cache-Control "public";
expires +1y;

if (!-f $request_filename) {
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
}
}

location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
add_header Cache-Control "no-store";
expires off;
try_files $uri $uri/ /index.php?$args;
}

if (!-f $request_filename) {
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
}
location /pub {
alias $MAGE_ROOT/pub;
}

}
location /static/ {
if ($MAGE_MODE = "production") {
expires max;
}
location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
add_header Cache-Control "public";
expires +1y;

if (!-f $request_filename) {
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
}
}

location /media/ {

location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
add_header Cache-Control "public";
expires +1y;

if (!-f $request_filename) {
rewrite / /get.php;
}
}

location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
add_header Cache-Control "no-store";
expires off;

if (!-f $request_filename) {
rewrite / /get.php;
}
}
location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
add_header Cache-Control "no-store";
expires off;

if (!-f $request_filename) {
rewrite / /get.php;
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
}
}

location /media/customer/ {
deny all;
if (!-f $request_filename) {
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
}
}

location /media/downloadable/ {
deny all;
location /media/ {
try_files $uri $uri/ /get.php?$args;
location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
add_header Cache-Control "public";
expires +1y;
try_files $uri $uri/ /get.php?$args;
}

location ~ /media/theme_customization/.*\.xml$ {
deny all;
location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
add_header Cache-Control "no-store";
expires off;
try_files $uri $uri/ /get.php?$args;
}
}

location /errors/ {
try_files $uri =404;
}
location /media/customer/ {
deny all;
}

location ~ ^/errors/.*\.(xml|phtml)$ {
deny all;
}
location /media/downloadable/ {
deny all;
}

location ~ cron\.php {
deny all;
}
location ~ /media/theme_customization/.*\.xml$ {
deny all;
}

location ~ (index|get|static|report|404|503)\.php$ {
expires -1;
fastcgi_pass fastcgi_backend;
location /errors/ {
try_files $uri =404;
}

fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=256M \n max_execution_time=600";
fastcgi_read_timeout 600s;
fastcgi_connect_timeout 600s;
fastcgi_param MAGE_MODE $MAGE_MODE;
location ~ ^/errors/.*\.(xml|phtml)$ {
deny all;
}

fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ cron\.php {
deny all;
}

location ~ (index|get|static|report|404|503)\.php$ {
try_files $uri =404;
fastcgi_pass fastcgi_backend;

fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=256M \n max_execution_time=600";
fastcgi_read_timeout 600s;
fastcgi_connect_timeout 600s;
fastcgi_param MAGE_MODE $MAGE_MODE;

fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

0 comments on commit 0c404fe

Please sign in to comment.