大网数据广告活动
服务器运维问答

How can I get my local network machines to call local web server by URL?

· 52CE 我爱测

I have four computers connected to a single switch - unconnected to the internet. One of the computers (the large one in the picture) is more powerful than the others and is running Ubuntu, with three live Node.js web servers wit…

问题原文

原帖链接 · CodyBugstein · CC BY-SA 3.0

I have four computers connected to a single switch - unconnected to the internet.

One of the computers (the large one in the picture) is more powerful than the others and is running Ubuntu, with three live Node.js web servers with different apps on different ports. The other computers are running Windows.

I want the other three computers to access the web servers by calling a URL, for example

  • files.bugsteins --> 192.168.0.5:3000
  • chat.bugsteins --> 192.168.0.5:3001
  • devices.bugsteins --> 192.168.0.5:3002

What is the best (priority to fastest set up time) way to accomplish this ?

Thus far I have tried Bind9 on the server machine and assigning static IPs and manual hardcoded DNS on the three client machines but it is not working and as I work on it, I figure I will post this question in case someone has a better way.

已采纳解答

原帖链接 · TessellatingHeckler · CC BY-SA 3.0

What is the best (priority to fastest set up time) way to accomplish this?

Not BIND.

Edit the c:\windows\system32\drivers\etc\hosts file on each desktop and point those names to 192.168.0.5.

192.168.0.5 files.bugsteins 
192.168.0.5 chat.bugsteins
192.168.0.5 devices.bugsteins

Add a web listener on port 80 on the server, somehow with your Node.js setup, or a basic webserver install (Lighttpd, NginX, Apache, or heaps of others) serving a static page with a JavaScript in it which looks at the URL and redirects the page to the appropriate port.

Taking from https://stackoverflow.com/questions/18022636/redirection-based-on-url-javascript something like this (untested):

<html>
<head><title>Redirect page</title></head>
<body>
<script type="text/javascript">

if (window.location.href== "http://files.bugsteins") {
   window.location.href = 'http://files.bugsteins:3000'; 
}

if (window.location.href== "http://chat.bugsteins") {
   window.location.href = 'http://chat.bugsteins:3001'; 
}

if (window.location.href== "http://devices.bugsteins") {
   window.location.href = 'http://devices.bugsteins:3002'; 
}

</script>
</body>
</html>

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-01-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。