简体   繁体   中英

run 3 web servers on the same port

Well i have a machine and i want to do a very simple thing, on this machine i have 3 DNS records, for example 111.111.111.111 is the ip of the machine itself

test1.whatever.net - 111.111.111.111
test2.whatever.net - 111.111.111.111
test3.whatever.net - 111.111.111.111
  • We would like the traffic coming through each DNS record to be handled by each corresponding service.
  • Create 3 very simple scripts that act as a website using any language or platform (suggested NodeJs), that echo the name of the service when calling the DNS record (eg "service1", "service2" and "service3").

how do i do that?

  • All of the services must run on port 80
  • The machine is AWS Linux 2

What http server are you using? Usually you can solve this issue with creating virtual hosts. In Apache it would look like this: https://httpd.apache.org/docs/2.4/vhosts/examples.html There you can define, based on the DNS request, which folder the webserver should use to present the client.

Another option, but this might be more complex, when you setup an nginx proxy. https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/

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