Skip to content

Commit

Permalink
feat: support magento multistore with nginx mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
janosmiko committed Feb 1, 2021
1 parent 2ebca79 commit f0df945
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.3-beta
0.1.4-beta
28 changes: 27 additions & 1 deletion docs/configuration/multipledomains.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,33 @@ Multiple top-level domains may also be setup by following the instructions below
- sub2.alternate2.test:${TRAEFIK_ADDRESS:-0.0.0.0}
```

### Magento 2 Run Params
### Magento 2 Run Params (eg. Magento Multi Store)

There are two (and many more) ways to configure Magento run params (`MAGE_RUN_TYPE`, `MAGE_RUN_CODE`).
* Nginx mappings
* Composer autoload

#### Nginx: Set MAGE_RUN_CODE/MAGE_RUN_TYPE by HTTP_HOST mapping

Add the following file to you project folder `./.reward/nginx/http-maps.conf` with the content.

Here's an example:
```
map $http_host $MAGE_RUN_CODE {
example.test default;
sub.example.test store_code_1;
website.example.test another_run_code;
default default;
}
map $http_host $MAGE_RUN_TYPE {
example.test store;
sub.example.test store;
website.example.test website;
default store;
}
```

#### Composer: Autoload php file

When multiple domains are being used to load different stores or websites on Magento 2, the following configuration should be defined in order to set run codes and types as needed.

Expand Down
4 changes: 2 additions & 2 deletions images/nginx/context/etc/nginx/available.d/magento1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ location ~ \.php$ {
fastcgi_param HTTP_X_REWRITE_URL "";
fastcgi_param HTTP_X_ORIGINAL_URL "";

# fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
# fastcgi_param MAGE_RUN_TYPE $MAGE_RUN_TYPE;
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
fastcgi_param MAGE_RUN_TYPE $MAGE_RUN_TYPE;

fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
Expand Down
3 changes: 3 additions & 0 deletions images/nginx/context/etc/nginx/available.d/magento2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ location ~ \.php$ {
fastcgi_busy_buffers_size 256k;
fastcgi_read_timeout 3600s;

fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
fastcgi_param MAGE_RUN_TYPE $MAGE_RUN_TYPE;

fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=18000";

Expand Down
7 changes: 7 additions & 0 deletions images/nginx/context/etc/nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ map "$http_X_BLACKFIRE_QUERY:$cookie_XDEBUG_SESSION$cookie_XDEBUG_PROFILE$cookie
default ${NGINX_UPSTREAM_DEBUG_HOST}:${NGINX_UPSTREAM_DEBUG_PORT};
}

map $http_host $MAGE_RUN_CODE {
default "";
}
map $http_host $MAGE_RUN_TYPE {
default "";
}

include /etc/nginx/snippets/http-*.conf;

server {
Expand Down

0 comments on commit f0df945

Please sign in to comment.