简体   繁体   English

尝试设置一个node.js Web服务器

[英]Trying to setup a node.js web server

I am new to web servers and node.js and I need some help. 我是Web服务器和node.js新手,我需要一些帮助。

I have no idea what to put in the .listen(); 我不知道在.listen()中放什么;

I think since I want it to connect to the internet the server needs to listen to port 80 but but I don't know what to put as the second value. 我想,因为我希望它连接到互联网,所以服务器需要侦听端口80,但我不知道将第二个值放在什么位置。

.listen(80, "What do I add here?");

Also i have a free domain name ( www.example.co.cc ) that is pointing to a dynamic dns (DnsExit) since I dynamic ip. 另外,我有一个免费域名( www.example.co.cc ),因为我是动态IP,所以它指向动态dns(DnsExit)。 I installed to program needed to update my ip address. 我安装了需要更新我的IP地址的程序。

Is there anything I am missing? 我有什么想念的吗?

Have you seen the example on the homepage of the Node.js project? 您是否在Node.js项目的主页上看到了示例?

It clearly demonstrated .listen( 1337, "127.0.0.1" ); 它清楚地显示了.listen( 1337, "127.0.0.1" ); and then the next line reads Server running at http://127.0.0.1:1337/ - so the second argument is the IP you want to listen on. 然后下一行读取Server running at http://127.0.0.1:1337/ -因此第二个参数是您要侦听的IP。 If you then take a look at the documentation you will see that this second argument is actually optional, if you omit it, Node.js will accept incoming connections directed at any IPv4 address. 如果再看一下文档,您会发现第二个参数实际上是可选的,如果省略它,Node.js将接受指向任何IPv4地址的传入连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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