Magento Multiple stores with nginx












0















I am following tutorials about magento ,it use nginx as server ,I created 2 different stores and edit the file /etc/nginx/sites-available/magento as follows :



map $http_host $mage_run_code {
default '';
gizmo.com gizmo_com;
widget.com widget_com;
}
map $http_host $mage_run_type {
default store;
gizmo.com webisite;
widget.com website;
}
server {
listen 80;

root /var/www/magento;

index index.php index.html index.htm;

server_name magento.local gizmo.com www.gizmo.com widget.com www.widget.com;

# Place PHP error logs in the Magento log folder
set $php_log /var/www/magento/var/log/php_errors.log;

# Replaces Apache rewrite rules
location / {
try_files $uri $uri/ @handler;
}

# Protect sensitive folders
location /app/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /var/ { deny all; }

# Protect dotfiles (htaccess, svn, etc.)
location /. { return 404; }

location @handler {
rewrite / /index.php;
}

# Remove trailing slashes from PHP files
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}

# Pass PHP to a the PHP-FPM backend
location ~ .php$ {
# Fix timeouts when installing Magento via web interface
fastcgi_send_timeout 1800;
fastcgi_read_timeout 1800;
fastcgi_connect_timeout 1800;

fastcgi_pass 127.0.0.1:9000;
#fastcgi_param HTTPS $fastcgi_https;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param MAGE_IS_DEVELOPER_MODE on; # Turn on developer mode
fastcgi_param MAGE_RUN_CODE $mage_run_code;
fastcgi_param MAGE_RUN_TYPE $mage_run_type;
fastcgi_param PHP_VALUE error_log=$php_log;
include fastcgi_params;
}
}


The strange thing is ,that when I open widget.com it is not giving me error,but redirect me to magento.local/ ,actually the url stays widget.com ,but I tried to change the html of widget.com through the admin site of magento and it doesn't change so I think it loads the default magento index page.When I try to open gizmo.com it shows me 404 error.I restarted nginx and did everything as in the tutorial ,but still same thing.










share|improve this question














bumped to the homepage by Community 16 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • are you sure these types are website not store ?? your base url is: http://gizmo.com not http://www.gizmo.com ??

    – MagenX
    Apr 26 '16 at 17:49
















0















I am following tutorials about magento ,it use nginx as server ,I created 2 different stores and edit the file /etc/nginx/sites-available/magento as follows :



map $http_host $mage_run_code {
default '';
gizmo.com gizmo_com;
widget.com widget_com;
}
map $http_host $mage_run_type {
default store;
gizmo.com webisite;
widget.com website;
}
server {
listen 80;

root /var/www/magento;

index index.php index.html index.htm;

server_name magento.local gizmo.com www.gizmo.com widget.com www.widget.com;

# Place PHP error logs in the Magento log folder
set $php_log /var/www/magento/var/log/php_errors.log;

# Replaces Apache rewrite rules
location / {
try_files $uri $uri/ @handler;
}

# Protect sensitive folders
location /app/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /var/ { deny all; }

# Protect dotfiles (htaccess, svn, etc.)
location /. { return 404; }

location @handler {
rewrite / /index.php;
}

# Remove trailing slashes from PHP files
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}

# Pass PHP to a the PHP-FPM backend
location ~ .php$ {
# Fix timeouts when installing Magento via web interface
fastcgi_send_timeout 1800;
fastcgi_read_timeout 1800;
fastcgi_connect_timeout 1800;

fastcgi_pass 127.0.0.1:9000;
#fastcgi_param HTTPS $fastcgi_https;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param MAGE_IS_DEVELOPER_MODE on; # Turn on developer mode
fastcgi_param MAGE_RUN_CODE $mage_run_code;
fastcgi_param MAGE_RUN_TYPE $mage_run_type;
fastcgi_param PHP_VALUE error_log=$php_log;
include fastcgi_params;
}
}


The strange thing is ,that when I open widget.com it is not giving me error,but redirect me to magento.local/ ,actually the url stays widget.com ,but I tried to change the html of widget.com through the admin site of magento and it doesn't change so I think it loads the default magento index page.When I try to open gizmo.com it shows me 404 error.I restarted nginx and did everything as in the tutorial ,but still same thing.










share|improve this question














bumped to the homepage by Community 16 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • are you sure these types are website not store ?? your base url is: http://gizmo.com not http://www.gizmo.com ??

    – MagenX
    Apr 26 '16 at 17:49














0












0








0


1






I am following tutorials about magento ,it use nginx as server ,I created 2 different stores and edit the file /etc/nginx/sites-available/magento as follows :



map $http_host $mage_run_code {
default '';
gizmo.com gizmo_com;
widget.com widget_com;
}
map $http_host $mage_run_type {
default store;
gizmo.com webisite;
widget.com website;
}
server {
listen 80;

root /var/www/magento;

index index.php index.html index.htm;

server_name magento.local gizmo.com www.gizmo.com widget.com www.widget.com;

# Place PHP error logs in the Magento log folder
set $php_log /var/www/magento/var/log/php_errors.log;

# Replaces Apache rewrite rules
location / {
try_files $uri $uri/ @handler;
}

# Protect sensitive folders
location /app/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /var/ { deny all; }

# Protect dotfiles (htaccess, svn, etc.)
location /. { return 404; }

location @handler {
rewrite / /index.php;
}

# Remove trailing slashes from PHP files
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}

# Pass PHP to a the PHP-FPM backend
location ~ .php$ {
# Fix timeouts when installing Magento via web interface
fastcgi_send_timeout 1800;
fastcgi_read_timeout 1800;
fastcgi_connect_timeout 1800;

fastcgi_pass 127.0.0.1:9000;
#fastcgi_param HTTPS $fastcgi_https;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param MAGE_IS_DEVELOPER_MODE on; # Turn on developer mode
fastcgi_param MAGE_RUN_CODE $mage_run_code;
fastcgi_param MAGE_RUN_TYPE $mage_run_type;
fastcgi_param PHP_VALUE error_log=$php_log;
include fastcgi_params;
}
}


The strange thing is ,that when I open widget.com it is not giving me error,but redirect me to magento.local/ ,actually the url stays widget.com ,but I tried to change the html of widget.com through the admin site of magento and it doesn't change so I think it loads the default magento index page.When I try to open gizmo.com it shows me 404 error.I restarted nginx and did everything as in the tutorial ,but still same thing.










share|improve this question














I am following tutorials about magento ,it use nginx as server ,I created 2 different stores and edit the file /etc/nginx/sites-available/magento as follows :



map $http_host $mage_run_code {
default '';
gizmo.com gizmo_com;
widget.com widget_com;
}
map $http_host $mage_run_type {
default store;
gizmo.com webisite;
widget.com website;
}
server {
listen 80;

root /var/www/magento;

index index.php index.html index.htm;

server_name magento.local gizmo.com www.gizmo.com widget.com www.widget.com;

# Place PHP error logs in the Magento log folder
set $php_log /var/www/magento/var/log/php_errors.log;

# Replaces Apache rewrite rules
location / {
try_files $uri $uri/ @handler;
}

# Protect sensitive folders
location /app/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /var/ { deny all; }

# Protect dotfiles (htaccess, svn, etc.)
location /. { return 404; }

location @handler {
rewrite / /index.php;
}

# Remove trailing slashes from PHP files
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}

# Pass PHP to a the PHP-FPM backend
location ~ .php$ {
# Fix timeouts when installing Magento via web interface
fastcgi_send_timeout 1800;
fastcgi_read_timeout 1800;
fastcgi_connect_timeout 1800;

fastcgi_pass 127.0.0.1:9000;
#fastcgi_param HTTPS $fastcgi_https;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param MAGE_IS_DEVELOPER_MODE on; # Turn on developer mode
fastcgi_param MAGE_RUN_CODE $mage_run_code;
fastcgi_param MAGE_RUN_TYPE $mage_run_type;
fastcgi_param PHP_VALUE error_log=$php_log;
include fastcgi_params;
}
}


The strange thing is ,that when I open widget.com it is not giving me error,but redirect me to magento.local/ ,actually the url stays widget.com ,but I tried to change the html of widget.com through the admin site of magento and it doesn't change so I think it loads the default magento index page.When I try to open gizmo.com it shows me 404 error.I restarted nginx and did everything as in the tutorial ,but still same thing.







magento-1.9 nginx






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 20 '16 at 19:44









dobrganchdobrganch

114




114





bumped to the homepage by Community 16 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 16 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • are you sure these types are website not store ?? your base url is: http://gizmo.com not http://www.gizmo.com ??

    – MagenX
    Apr 26 '16 at 17:49



















  • are you sure these types are website not store ?? your base url is: http://gizmo.com not http://www.gizmo.com ??

    – MagenX
    Apr 26 '16 at 17:49

















are you sure these types are website not store ?? your base url is: http://gizmo.com not http://www.gizmo.com ??

– MagenX
Apr 26 '16 at 17:49





are you sure these types are website not store ?? your base url is: http://gizmo.com not http://www.gizmo.com ??

– MagenX
Apr 26 '16 at 17:49










1 Answer
1






active

oldest

votes


















0














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.







share|improve this answer
























  • there is no point to duplicate this config, you have now more problematic to maintain...

    – MagenX
    Apr 26 '16 at 17:52











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f111828%2fmagento-multiple-stores-with-nginx%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














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.







share|improve this answer
























  • there is no point to duplicate this config, you have now more problematic to maintain...

    – MagenX
    Apr 26 '16 at 17:52
















0














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.







share|improve this answer
























  • there is no point to duplicate this config, you have now more problematic to maintain...

    – MagenX
    Apr 26 '16 at 17:52














0












0








0







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.







share|improve this answer













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.








share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 21 '16 at 7:33









AlistairAlistair

33639




33639













  • there is no point to duplicate this config, you have now more problematic to maintain...

    – MagenX
    Apr 26 '16 at 17:52



















  • there is no point to duplicate this config, you have now more problematic to maintain...

    – MagenX
    Apr 26 '16 at 17:52

















there is no point to duplicate this config, you have now more problematic to maintain...

– MagenX
Apr 26 '16 at 17:52





there is no point to duplicate this config, you have now more problematic to maintain...

– MagenX
Apr 26 '16 at 17:52


















draft saved

draft discarded




















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f111828%2fmagento-multiple-stores-with-nginx%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

What other Star Trek series did the main TNG cast show up in?

Berlina muro

Berlina aerponto