Мои настройки Nginx + PHP-FPM для запуска Magento 2.0 в подпапке

Ниже мои реальные настройки для домена mage2.pro (Nginx + PHP-FPM).
Запрос к https://mage2.pro обрабатывается движком Discourse (смотрите российский форум Discourse и мои плагины для Discourse).
https://mage2.pro/store обрабатывается Magento 2.0

Смотрите также:

server {
	listen 80;
	server_name mage2.pro;
	return 301 https://$server_name$request_uri;
}
server {
	server_name www.mage2.pro;
	rewrite ^ https://mage2.pro$request_uri? permanent;
}
server {
	listen 443 ssl;
	server_name mage2.pro;
    ssl_certificate certificates/mage2.pro/PositiveSSL/bundle.crt;
    ssl_certificate_key certificates/mage2.pro/PositiveSSL/.key;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	error_page 419 = @magento;
	proxy_set_header X-Forwarded-Proto $scheme;
	location ~ /\. {deny all;}
	location /store {
		root /var/www/mage2.pro;
		location = /store {rewrite /store /store/index.php last;}
		location = /store/ {rewrite /store /store/index.php last;}
		location = /store/setup {rewrite /store /store/setup/index.php last;}
		location = /store/setup/ {rewrite /store /store/setup/index.php last;}
		location /store/setup {
			location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
				access_log off;
				expires max;
				try_files $uri =404;
			}
			location /store/setup/index.php {return 419;}
		}
		location /store/pub/ {
			location /store/pub/media/ {
				location /store/pub/media/customer/ {deny all;}
				location /store/pub/media/downloadable/ {deny all;}
				location ~ /store/pub/media/theme_customization/.*\.xml$ {deny all;}
				try_files $uri $uri/ /store/pub/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/ /store/pub/get.php?$args;
				}
				location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
					add_header Cache-Control "no-store";
					expires off;
					try_files $uri $uri/ /store/pub/get.php?$args;
				}
			}
			location /store/pub/static/ {
				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 ^/store/pub/static/(version\d*/)?(.*)$ /store/pub/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 ^/store/pub/static/(version\d*/)?(.*)$ /store/pub/static.php?resource=$2 last;
					}
				}
				if (!-f $request_filename) {
					rewrite ^/store/pub/static/(version\d*/)?(.*)$ /store/pub/static.php?resource=$2 last;
				}
			}
			location ~ ^/store/pub/errors/.*\.(xml|phtml)$ {deny all;}
			location /store/pub/errors/ {try_files $uri =404;}
			location = /store/pub/cron.php {deny all;}
		}
		location ~ (index|get|static|report|404|503|phpinfo)\.php$ {return 419;}
		if (-e $request_filename) {return 403;}
		rewrite /store /store/index.php last;
	}
	location / {
		root /var/www/res/discourse;
		access_log off;
		expires max;
		try_files $uri @discourse;
	}
	location @discourse {
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header Host $http_host;
		proxy_set_header X-Forwarded-Proto $scheme;
		proxy_redirect off;
		proxy_pass http://mage2_pro;
	}
	location @magento {
		root /var/www/mage2.pro;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		fastcgi_param MAGE_MODE developer;
		include fastcgi_params;
		fastcgi_pass 127.0.0.1:9000;
	}
}