-5

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?

2

1 Answer 1

0

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.

2
  • Then you just need to setup some name-based vhosts. The relevant config files for you on Ubuntu (or any other Debian like distro) is in /etc/apache and /etc/apache/sites-available. Ubuntu should also have the a2ensite to enable sites (vhosts) after you've created them.
    – Wuhtzu
    May 1, 2014 at 7:35
  • even I didn't use a2ensite it is still working as i expected. but to be sure I added a2ensite as what you suggested. Thanks! May 1, 2014 at 7:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.