How to set up multiple websites on a server with one static IP?

6

2

I have a server which has one static IP address (let's say it's x.x.x.x). How can I set up multiple websites on this server?

What I can think of is creating multiple website and publish them through different ports. So I can access website 1 from x.x.x.x:8081 and website 2 from x.x.x.x:8082 etc. Then register different domains and point to x.x.x.x:8081 and x.x.x.x:8082 separately. Is that the correct way? This is the first time I'm doing this kind of work and I lack of confidence. Can anyone point me the right direction?

Also can anyone describe how to configure the domain(s) in my situation? Thanks.

user130268

Posted 2013-05-27T13:34:53.410

Reputation: 161

What server software are you using? Apache? Lighttpd? – Jorge Fuentes González – 2013-05-27T13:39:48.273

1this is exactly the reason why the host header was made mandatory in http 1.1 – ratchet freak – 2013-05-27T15:17:45.380

Answers

7

As suggested, virtual hosts will allow this. I just want to add that since you are going to register different domains, you do NOT need to use a separate port for each. Each domain can use e.g. port 80. Apache will figure out which virtual host to use by the name.

BostonDriver

Posted 2013-05-27T13:34:53.410

Reputation: 452

4

What you need to set up are virtual hosts. I'm going to take a wild guess and assume you are running apache. There are instructions on the apache website which will point you in the right direction. Every webserver I can think of supports virtual hosts of some kind, so if you don't run apache, you'll have to google instructions for your webserver accordingly.

SBI

Posted 2013-05-27T13:34:53.410

Reputation: 771

2

It depends on the web server software, but I think today most servers (certainly Apache) offers multiple sites through the same IP (the web browsers, connecting the server request the name of the site too).

The name to look for (google for) is "virtual host", e.g. here is a link showing an example with the Apache server.

The-Dood

Posted 2013-05-27T13:34:53.410

Reputation: 60

1

As suggested before , Apache can do this , check this : http://www.thegeekstuff.com/2011/07/apache-virtual-host/

Scorpion99

Posted 2013-05-27T13:34:53.410

Reputation: 1 023

0

You can have as many domains as you like with 1 IP address if you create separate directories for each domain, and then set up virtual host on the server for each directory. You then need to log in to your DNS provider and set up URL redirect for each domain.

Thomas Lee

Posted 2013-05-27T13:34:53.410

Reputation: 1

1Hi Thomas Lee, welcome to Super User. Can you expand a bit on this? The other answers also refer to virtual hosts, so adding some additional information might help your answer stand out. – bertieb – 2017-02-20T23:49:10.607

-1

You can also set up server blocks (essentially virtual hosts) if you are using nginx as your web server. There are step by step instructions for setting it up on an Ubuntu 16.04 DigitalOcean droplet located here, and the nginx documentation can be found here.

J-Eubanks

Posted 2013-05-27T13:34:53.410

Reputation: 1