How to configure multiple websites #456
Replies: 4 comments 25 replies
-
I think it would help if there was a configuration in the |
Beta Was this translation helpful? Give feedback.
-
(I deleted the previous message as I sent it from another account) Hello, I tried to follow several tutorials, including Mark's lesson and still can't run websites using the "folders approach". Almost all the documentation available on the internet is focussed on subdomains: site1.domain.com/, site2.domain.com/, site3.domain.com/. What I'm trying to configure with no luck is: domain.com/site1/, domain.com/site2/, domain.com/site3/. I'm not an expert in almost nothing, including Nginx :D however, I know that running sites using the folders configuration is a very common scenario and I wouldn't expect it's this difficult to both: find information about how to implement it using Nginx, and actually making it work. Can anybody please point me out in the right direction, or give some hints? Thank you! |
Beta Was this translation helpful? Give feedback.
-
Right now, Mark's tutorial works almost perfect, in my case i added this line inside Dockerfile, so it ends up like this: FROM markoshust/magento-nginx:1.18-8 Hope this helps someone. |
Beta Was this translation helpful? Give feedback.
-
Here's what worked for me for 3 websites. 1 - Stop the containers. 2 - Change "compose.yaml" nginx:
3 - Change "compose.dev.yaml" to include "nginx.conf":
4 - Create "Doxkerfile" under "images/nginx/Dockerfile" with this content:
5 - Create "default.conf" under "images/nginx/conf/default.conf" and "Doxkerfile" :
6 - Change "nginx.conf" PHP entry like this:
7 - Start the containers "bin/start" 8 - Setup the domains (I ran for all of them but tbh I don't know if it is needed) 9 - Change your database URLs by replacing the base URLs for each website scope with your domains: 10 - Flush the cache That's it. Cheers |
Beta Was this translation helpful? Give feedback.
-
This was writen by Marks (the guru) in a comment on his course and save my day...
https://courses.m.academy/courses/487758/lectures/9064349
Change your docker-compose.yml file to:
...
services:
app:
build: images/nginx
...
Create a file at images/nginx/Dockerfile with the contents:
FROM markoshust/magento-nginx:1.18-3
COPY ./conf/default.conf /etc/nginx/conf.d/
Then create a file at images/nginx/conf/default.conf with the contents:
upstream fastcgi_backend {
server unix:/sock/docker.sock;
}
map $http_host $MAGE_RUN_CODE {
default base;
domain1.test base;
domain2.test other_website; # Put your secondary website code here
# Add any other domains here using the same method
}
server {
listen 8000;
return 301 https://$host$request_uri;
}
server {
listen 8443 ssl;
ssl_certificate /etc/nginx/certs/nginx.crt;
ssl_certificate_key /etc/nginx/certs/nginx.key;
server_name
domain1.test
domain2.test
# And any others...
;
set $MAGE_ROOT /var/www/html;
set $MAGE_RUN_TYPE website;
include /var/www/html/nginx.conf;
}
You will also need to copy your src/nginx.conf.sample file over to src/nginx.conf, and update the contents of this block to include the MAGE_RUN_TYPE and MAGE_RUN_CODE variables:
...
location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check).php$ {
try_files $uri =404;
fastcgi_pass fastcgi_backend;
fastcgi_buffers 1024 4k;
}
...
Be sure to also update your docker-compose.dev.yml volume mounts if you are non-linux, so that your nginx reference looks at the new file:
...
services:
app:
volumes: &appvolumes
# Host mounts with performance penalty, only put what is necessary here
- ./src/app/code:/var/www/html/app/code:delegated
...
- ./src/nginx.conf:/var/www/html/nginx.conf:delegated
...
Then, running bin/restart will rebuild the app service with the new Docker container. Hope this helps :)
Beta Was this translation helpful? Give feedback.
All reactions