You do not need to change your nameservers at all - that's only relevant when you are changing DNS providers.
For each website, add an A
record from the root domain to the IP address of your server, and an A
record from the www
subdomain to the IP address of your server.
When someone makes a request to one of your domains, the request will arrive to nginx with a HTTP Host
header that indicates which domain they want to communicate with. In the nginx config file, you will need to set up virtual servers to proxy the request depending on the Host
header, like so:
server {
listen 80;
server_name example1.com;
location / {
proxy_pass http://127.0.0.1:8080; # The port that web service 1 is running on
}
}
server {
listen 80;
server_name example2.com;
location / {
proxy_pass http://127.0.0.1:8181; # The port that web service 2 is running on
}
}
You will also want to set up redirects from your bare domain to www, or from www to your bare domain, like this:
server {
listen 80;
server_name example1.com;
return 301 http://www.example1.com$request_uri;
}
server {
listen 80;
server_name example2.com;
return 301 http://www.example2.com$request_uri;
}