I want to run several .NET Core sites on a Linux server with Docker
I also want to assign a domain to each of the sites
I have two questions
- Do I have to assign the domain to the site with the help of a web server like nginx?
- Do I have to create a yml file service for each site and each with a separate nginx, or run a nginx for all sites?
2
Answers
Thank you. The explanation was complete.
I have different domains and i want to assign each domain name to one service. also i'm set A records before. for example :
my question is : It is enough to run one nginx container for all the above services(http://www.myservice1.com, http://www.myservice2.com, http://www.myservice3.com) or I have to run a separate nginx container for each
Assuming that you mean a public (Internet) domain name, there are a few steps.
Domains in this context comprise a unique identifying name e.g.
example.com
and a set of resource records that explain how the domain is used.In your case, you probably need to use
A
(ddress) record(s) that map hosts (!) on your domain to the IP(v4) address of the machines (!) running your containers.A domain name
A
record (e.g.www.example.com
) combines a host name (www
) with a domain name (example.com
) and resolves (points) to the IP(v4) address of (host) machine(s).The (host) machines may run e.g. multiple containers (services) each running on a specific port. To address (using a URL) a specific service, you combine a protocol, a host name, a domain name and a port (e.g.
https://www.example.com:8443
).NGINX permits you to proxy multiple services behind a single service endpoint. NGINX is also a web server but I’m treating it solely as a (reverse) proxy in what follows.
Assuming that your NGINX service were running on port
8443
on the hostwww
on the machine pointed to by theA
record in your domain, you could program NGINX to proxy content such that, the URL (address)https://www.example.com:8443/service-1
andhttps://www.example.com:8443/service-2
are actually sent to other containers (which may or may not be running onwww
and are probably bound to a different ports).