Reputation: 101
I want to use 2 web sites inside a ddev web container but can't find out how to configure nginx the right way. I have set up the additional_hostname to site-a and site-b to let me access the web site with site-a.ddev.site and site-b.ddev.site. The web sites are in different local directories site-a and site-b.
How can I define the "sites-available" and "sites-enabled" configuration for nginx? In the documentation I found only the way to create a .ddev/nginx-site.conf file, but with this I can only configure one web site.
I know that I can "ddev ssh" into the container and configure it by hand, but it should configure automatic when I checkout the project and made a "ddev configure" and "ddev start".
Upvotes: 1
Views: 627
Reputation: 12975
Two different hostnames is really easy, you just use additional_hostnames
or additional_fqdns
in .ddev/config.yaml. See docs.
But from the context of your question, I assume you want to have two different docroots in the nginx config, which respond to different hostnames. If that's right, here are some options:
#######################################################
# 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 ca.example.com.ddev.site;
#redifne your root
root /var/www/html/lang/en_ca;
include /etc/nginx/nginx_default.conf;
# this directive is unique to our set up, but demonstrates
# you can do more directives per site like this
location ~ \.php$ {
root /var/www/html/lang/en_ca;
}
}
The same issue is tackled the same way in https://github.com/drud/ddev/issues/1850#issuecomment-547461968 for more context.
Upvotes: 1