This 'map' config is far from ideal.
I've seen a few examples use the 'map' technique but it is really short sighted and full of general issues.
Best way to get mutli store running, start with one store, etc/nginx/sites-available/widget.com.conf and use the very basic nginx examples to get it running and in your the location ~ .php$ { location to point to the store name and check that it's still running:
fastcgi_param MAGE_RUN_CODE widgets;
fastcgi_param MAGE_RUN_TYPE store;
When this is all working perfectly ?
You can copy&past this config to /etc/nginx/sites-available/gizmo.com.conf
then change your store code to the other store in this config:
fastcgi_param MAGE_RUN_CODE gizmo;
fastcgi_param MAGE_RUN_TYPE store;
This will allow you to have a .config for each of your main stores.
All based on a single proven store.
With each having their own abilities, such as SSL/TLS and other really handy things for a webstore, like SiteMap locations etc. etc.)
Using this working example, you can add as many stores as you want by copying the working config and changing the store code in the php location block, each having their own .config file and each having their own settings where needed.
Here's a copy of my Nginx config to get you started:
Widgets.com.conf
server {
listen 443 ssl;
listen 80;
server_name www.widgets.com widgets.com;
keepalive_timeout 70;
root /home/mysite/public_html/;
index index.php;
try_files $uri $uri/ @handler;
client_max_body_size 150M;
client_body_buffer_size 80M;
client_header_timeout 360;
client_body_timeout 360;
server_tokens off;
send_timeout 360;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
ssl_certificate /home/ssl/widgets/combied.crt;
ssl_certificate_key /home/ssl/widgets/widgets.com.key;
add_header 'Strict-Transport-Security' 'max-age=31536000; preload;';
add_header 'Access-Control-Allow-Origin' '*';
location @ourcleanurls {
rewrite ^/(.*) /catalogsearch/advanced/result/?name=$1 last;
}
location ^~ /report/config.xml { deny all; }
location ^~ /var/ { deny all; }
location ^~ /admin/ { deny all; }
location ^~ /shell/ { deny all; }
location ^~ /app/ { deny all; }
location ^~ /includes/ { deny all; }
location ^~ /lib/ { deny all; }
location ^~ /media/downloadable/ { deny all; }
location ^~ /pkginfo/ { deny all; }
location @handler {
rewrite / /index.php;
}
location ~ \.php$ {
expires off; ## Do not cache dynamic content
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE widgets;
fastcgi_param MAGE_RUN_TYPE store;
fastcgi_read_timeout 9000;
fastcgi_send_timeout 9000;
include fastcgi_params;
proxy_read_timeout 9000;
proxy_connect_timeout 9000;
send_timeout 9000;
fastcgi_pass widgets-socket;
add_header 'Strict-Transport-Security' 'max-age=31536000; preload;';
add_header 'Alternate-Protocol' '443:npn-spdy/3';
}
gizmo.com.conf
server {
listen 443 ssl;
listen 80;
server_name www.gizmo.com gizmo.com;
keepalive_timeout 70;
root /home/mysite/public_html/;
index index.php;
try_files $uri $uri/ @handler;
client_max_body_size 150M;
client_body_buffer_size 80M;
client_header_timeout 360;
client_body_timeout 360;
server_tokens off;
send_timeout 360;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
ssl_certificate /home/ssl/gizmo/combied.crt;
ssl_certificate_key /home/ssl/gizmo/gizmo.com.key;
add_header 'Strict-Transport-Security' 'max-age=31536000; preload;';
add_header 'Access-Control-Allow-Origin' '*';
location @ourcleanurls {
rewrite ^/(.*) /catalogsearch/advanced/result/?name=$1 last;
}
location ^~ /report/config.xml { deny all; }
location ^~ /var/ { deny all; }
location ^~ /admin/ { deny all; }
location ^~ /shell/ { deny all; }
location ^~ /app/ { deny all; }
location ^~ /includes/ { deny all; }
location ^~ /lib/ { deny all; }
location ^~ /media/downloadable/ { deny all; }
location ^~ /pkginfo/ { deny all; }
location @handler {
rewrite / /index.php;
}
location ~ \.php$ {
expires off; ## Do not cache dynamic content
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE gizmo;
fastcgi_param MAGE_RUN_TYPE store;
fastcgi_read_timeout 9000;
fastcgi_send_timeout 9000;
include fastcgi_params;
proxy_read_timeout 9000;
proxy_connect_timeout 9000;
send_timeout 9000;
fastcgi_pass gizmo-socket;
add_header 'Strict-Transport-Security' 'max-age=31536000; preload;';
add_header 'Alternate-Protocol' '443:npn-spdy/3';
}
You can see, by copying the config to a new file you now have full control over things like SSL/TLS and many other things you really should have for a eCommerce store.
In the above configs i have choose to block all access attempts to /admin , if you are copying this exactly without reading it all first( you shouldn't ), you must make sure you have chosen a custom admin path, or comment out that line.
The first problem I can't find a solution for is how to tell Apache to rewrite (?) the static assets
Actually, you don't need to do that. Instead of setting http://siteA.mydomain.com/de/
as Base URL
, set it as Base Link URL
, and keep the Base URL
as http://siteA.mydomain.com/
, configuring it in the website level. This will tell Magento to look for assets on your root path, so you don't even need to rewrite the static files, whilst the URLs for products and other links will be generated using /de/
.
So you configuration for aa_de
should look like this:
(Base URL is configured in the website level, while the Base Link URL is configured in the store level)
Best Answer
at http{ } block:
at php${ } block: