server {
listen 80;
server_name <домен магазина>;
index index.php;
set $MAGE_MODE developer;
set $MAGE_ROOT <файловый путь к корневой папке без «/» на конце>;
root $MAGE_ROOT/pub;
autoindex off;
charset off;
location /setup {
root $MAGE_ROOT;
location ~ ^/setup/index.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_read_timeout 3600;
fastcgi_connect_timeout 3600;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
location / {
proxy_set_header X-Forwarded-Proto $scheme;
try_files $uri $uri/ /index.php?$args;
}
location /pub {
proxy_set_header X-Forwarded-Proto $scheme;
alias $MAGE_ROOT/pub;
}
location /static/ {
proxy_set_header X-Forwarded-Proto $scheme;
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;
if (!-f $request_filename) {
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
}
}
if (!-f $request_filename) {
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
}
}
location /media/ {
proxy_set_header X-Forwarded-Proto $scheme;
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 ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
add_header Cache-Control "no-store";
expires off;
try_files $uri $uri/ /get.php?$args;
}
}
location /media/customer/ {deny all;}
location /media/downloadable/ {deny all;}
location ~ /media/theme_customization/.*\.xml$ {deny all;}
location /errors/ {try_files $uri =404;}
location ~ ^/errors/.*\.(xml|phtml)$ {deny all;}
location ~ cron\.php {deny all;}
location ~ (index|get|static|report|404|503)\.php$ {
proxy_set_header X-Forwarded-Proto $scheme;
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=1500M \n max_execution_time=0";
fastcgi_read_timeout 3600;
fastcgi_connect_timeout 3600;
fastcgi_param MAGE_MODE $MAGE_MODE;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
server_name www.<домен магазина>;
proxy_set_header X-Forwarded-Proto $scheme;
rewrite ^ http://<домен магазина>$request_uri? permanent;
}
Смотрите также:
- настройки Nginx + PHP-FPM для запуска Magento 2.0 в подпапке: Мои настройки Nginx + PHP-FPM для запуска Magento 2.0 в подпапке
- настройки Nginx + Apache для запуска Magento 2.0 на локальном компьютере по корневому адресу (не в подпапке): Мои настройки Nginx + Apache для запуска Magento 2.0 на локальном компьютере
- настройки Nginx + Apache для запуска Magento 2.0 на локальном компьютере в подпапке: Мои настройки Nginx + Apache для запуска Magento 2.0 на локальном компьютере в подпапке