I am new to using nginx and am unsure as to what solution I should tackle this problem with.
I would like to have multiple domains pointing to one single virtual host in nginx.
So, for example: the domains example.one.com
and example.two.com
would point to virtual host hub.site.com
.
I am running nginx and nginx-gen (jwilder/docker-gen) as Docker containers. Config settings for nginx are therefore being defined based on the arguments specified in the run command of other Docker containers. For example:
docker run -d \
--restart=unless-stopped \
--name hub \
--network local \
-e VIRTUAL_HOST=hub.site.com \
-e VIRTUAL_PORT=3000 \
-e LETSENCRYPT_HOST=hub.site.com \
-e [email protected] \
-e FRONTEND='https://hub.site.com/' \
site/hub
Here, everything with the -e
flag gets recognized and implemented into the nginx config.
If there's a way to specify multiple domains to point to hub.site.com
from this run command, it would solve my problem whilst still using the current flow for defining settings for the nginx config.
The only other solution I know of would be directly editing the nginx config and using the method from this thread. Although that would go against my current flow for defining nginx config settings.
The jwilder/docker-gen is generate docker-compose.yml for jwilder/nginx-proxy In the document say:
Multiple Hosts If you need to support multiple virtual hosts for a container, you can separate each entry with commas. For example, foo.bar.com,baz.bar.com,bar.com and each host will be setup the same.
So you can add multiple domains to a single host by separating them with commas: