Preventing Domain from using VPS IP Address and Display its content [closed]

how can i prevent user from displaying contents of my vps. Currenty, I have an Ubuntu-powered vps and I install wordpress blog on it which is intended for my domain1.com. I know its possible to use the VPS IP to another domain by adding an A record which points to the IP. But i have a domain2.com and when i add an A Record to it. It will display the blog from domain1.com and also, when I try to key in IP address to the browser, I can see the blog I made. How can I specify its content that is viewable only for that particular domain?

Answer

Your VPS runs a web server (Apache, nginx or similar) and the web server needs to be setup to “handle multiple domains”. In more technical terms you need to setup some virtual hosts or vhosts to serve each of the domains you want to host.

If you only have one IP address you will need to do name-based vhosting where the web server decides the content based on the hostname the user types into his/her browser. E.g. you will have one vhost for domain1.com and one vhost for domain2.com. If someone sets up their own DNS and makes domain3.com point to your VPS then they will be served the default vhost. It is configurable which one is default.

See here for Apache name-based vhosting: https://httpd.apache.org/docs/2.2/vhosts/name-based.html

If you are not using Apache tell us what you use.

Attribution
Source : Link , Question Author : user3541736 , Answer Author : Wuhtzu

Leave a Comment