简体   繁体   中英

Linux Ubuntu 14.04 running 2 websites on 2 different web servers on 1 machine 1 ip

I am curious. Say I want so setup two domain names pointing to two web servers, on a single machine. I want one domain pointed to an apache web server and one pointed to a node web server. My intuition as a newby to servers is that I can't use a virtual host since only one site is using apache and I should probably run each on a separate VM, but I don't want to do that, so I figure if its all on one machine, I should just run each on different ports and then specify that in each domain. Is that the best way? Sorry I am all too new to this

Thanks to all!!

Limitations

HTTP is using TCP/IP protocol on the port 80. If you serve content from other ports - URL's will be something like: http://mysite:123/ (where 123 is the port).

Only a single socket can be opened for a IP:protocol:port combination. Since we have one IP, protocol and port are not flexible - thus only one application can serve the data. Having two domains do not lift this limitation.

Solution

You need a so called HTTP proxy, which would be the main entry point. And let this proxy decide what application shall handle the request.

Since you differentiate by domains, the proxy can be configured to respond based on domain requested.

There are a great amount of applications to serve this, main players are nginx and HTTPD Apache .

Since you already have Apache, you might continue using it, the subjects you need to look into:

  1. Setting up virtual hosts (differentiating by domain)
  2. Configuring proxy (to link virtual host to your node website).

Node can be used as a proxy too, but it is challenging to configure one for the production.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM