I am quite new to nginx and could not figure out how to configure nginx for the following scenario:
I have a domain domain1.com at some web hoster. There, an nginx server is running on a VPS serving for domain1.com -> everything is running as expected.
I have a domain domain2.com at another web hoster. There, I configured domain2.com to be forwarded to the IP of my VPS at the first web hoster. This does not work. Calling domain2.com via browser leads to a 404 error.
My nginx configuration looks like this:
server {
root /var/www/domain2.com/public;
index index.html;
server_name domain2.com www.domain2.com;
location / {
root /var/www/domain2.com/public/html;
try_files $uri $uri/ =404;
}
}
What's missing? I guess that I have to tell nginx somehow how to get the original domain (domain2.com) since (as I assume) it currently uses the IP/domain of the second web hoster to identify the correct config. But I do not know how I can do this.