There is a Yii framework written in PHP and it has advanced template. They even have their own docker setup, which I've tried and failed. The advanced template consists of project root and two separate directories frontend backend which are two different domains that use the project root - probably directory common is important.
I would like to have one ddev setup pointing to two different directories with two different domains and share the base.
I've tried to modify docker-compose inside .ddev folder.
Is it even possible now maybe? I can fire up frontend and backend separately but not at the same time.
Thank you.
Hi @arysom -
If I understand right you're talking about two different webservers with two different docroots. There are a number of ways to approach this:
ddev config in each of those and you'd have two ddev projects but one set of code.I've tried 2. and 4. but can't make it. I think I'll go with custom nginx configuration.
Hi @rfay . I've reported this issue as "feature request" . This could be useful if we could easily add two webroots at the same time. But of course it would be a bonus. I'm satisfied how the ddev now works and I recommend this project. Feel free to close this issue. Thank you.
Thanks @arysom - Could you give some detail here about how you solved it? Alternately, do a PR with more extensive description of how to solve it in https://github.com/drud/ddev-contrib
I mean I would like to request such feature :) For now, I haven't solved this yet.
@arysom you should take a look at the solution in https://github.com/drud/ddev/issues/1889
Hi @rfay ,
this could be solution, I confirm that the second hostname appeared after ddev start . I've set webroot up one dir and set in nginx-site.conf $WEBSERVER_DOCROOT/frontend/web and $WEBSERVER_DOCROOT/backend/web respectively.
# Set https to 'on' if x-forwarded-proto is https
map $http_x_forwarded_proto $fcgi_https {
default off;
https on;
}
server {
listen 80;
listen [::]:80 default ipv6only=on;
# The WEBSERVER_DOCROOT variable is substituted with
# its value when the container is started.
root $WEBSERVER_DOCROOT/frontend/web;
include /etc/nginx/monitoring.conf;
include /etc/nginx/nginx_default.conf;
include /mnt/ddev_config/nginx/*.conf;
}
server {
listen 443 ssl;
listen [::]:443 default ipv6only=on;
# The WEBSERVER_DOCROOT variable is substituted with
# its value when the container is started.
root $WEBSERVER_DOCROOT/frontend/web;
ssl_certificate /etc/ssl/certs/master.crt;
ssl_certificate_key /etc/ssl/certs/master.key;
include /etc/nginx/monitoring.conf;
include /etc/nginx/nginx_default.conf;
include /mnt/ddev_config/nginx/*.conf;
}
#######################################################
# EXAMPLE SITE ADDED TO DEFAULT NGINX
# THIS ASSUMES server_name: matches a name added to
# additional_hostnames: in your config.yaml
#
# CANADA - EN
#######################################################
server {
listen 80;
server_name mybackendhostname.ddev.site;
#redifne your root
root $WEBSERVER_DOCROOT/backend/web;
include /etc/nginx/nginx_default.conf;
}
Also I've set additional hostnames option in config.yaml
additional_hostnames:
- mybackendhostname
Maybe someone could write a line about this in docs.
Thank you.
What about adding something like this include /mnt/ddev_config/nginx/sites/*.conf; after the last server block? This would avoid to override the whole configuration and add the possibility to add new servers. Same for Apache ofc
I'm going to close this one in favor of #1889 , thanks all!
Most helpful comment
Hi @rfay ,
this could be solution, I confirm that the second hostname appeared after
ddev start. I've set webroot up one dir and set in nginx-site.conf$WEBSERVER_DOCROOT/frontend/weband$WEBSERVER_DOCROOT/backend/webrespectively.Also I've set additional hostnames option in config.yaml
Maybe someone could write a line about this in docs.
Thank you.