[英]How can I make my home PC a web server using node.js
If you have any ideas about the possibility of allow my friend to access my node.js web page by browser from her computer .. she lives out side my town i tried one method which is 如果您对允许我的朋友通过浏览器从她的计算机访问我的node.js网页的可能性有任何想法,那么她住在我镇附近,我尝试了一种方法
var http = require('http'); http.createServer(function(req, res){ res.writeHead(200, {'content-type': 'text/plain'}); res.end('It works'); }).listen(3000, '0.0.0.0'); //listening all interfaces
it works correctly but with the computer which locate on the same LAN network 它可以正常工作,但可以与位于同一局域网中的计算机配合使用
You could to configure your router to allow in route to your server port. 您可以配置路由器以允许路由到服务器端口。
If you have a fix IP, you don't need more things. 如果您有固定IP,则不需要更多东西。 If your IP vary along the days, you can to configure your router to use a dynamic IP. 如果您的IP随时间变化,则可以将路由器配置为使用动态IP。
I use https://www.dtdns.com/ , a free dynamic dns provider, to allow an external URL to access my home "server" (a Raspberry PI). 我使用https://www.dtdns.com/ (免费的动态dns提供程序)来允许外部URL访问我的家庭“服务器”(Raspberry PI)。
But, already, it starts at configure your router, or, also, using the tunnel listed after, by I believe configuring your modem it's more fast to access (more kb/s) than using tunnel. 但是,它已经开始于配置路由器,或者也使用下面列出的隧道,因为我相信配置调制解调器比使用隧道更快速地访问(更多kb / s)。
Better to have Linux based operating system 拥有基于Linux的操作系统更好
/var/www/yourappname
on Linux and ~/Sites
on Mac 将您的应用复制到Linux上的/var/www/yourappname
和Mac上的~/Sites
:80
) into browser 只需在浏览器中输入您的静态地址和端口( 如果不同于 :80
) If you're doing this - first time, it may looks a bit tricky and can take a day or two. 如果您是第一次这样做,可能会有些棘手,可能需要一两天。 But after few server setups - you will be able to do same operations with closed eyes. 但是,只需进行几次服务器设置,您就可以闭眼执行相同的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.