简体   繁体   English

Node.js-将其公开吗?

[英]Node.js - Taking it public?

I'm learning how to program in Node.js, and so far I've been able to run it using my computer as a server, and log in through an IP address:8080 from other computers on the same router. 我正在学习如何在Node.js中进行编程,到目前为止,我已经能够使用我的计算机作为服务器来运行它,并且可以通过IP地址:8080从同一路由器上的其他计算机登录。 But for the life of me, I can't seem to find any tutorials or anything for taking it public. 但是对于我的一生来说,我似乎找不到任何教程或将其公开的任何内容。 Eg using my laptop from work to connect to the server hosted at home. 例如,下班时使用笔记本电脑连接到家里托管的服务器。 I've searched free servers and am completely mixed up on SSH keys and github requirements and stuff with a bunch of others. 我搜索了免费服务器,并完全混淆了SSH密钥和github要求以及其他内容。 I'm really mixed up. 我真的好混。 I'm also thinking it would be much simpler (and 100% free on monthly payments) to buy my own hardware and run my own servers? 我还认为购买自己的硬件并运行自己的服务器会简单得多(每月付款100%免费)? Any tutorials on node.js hardware set ups? 关于node.js硬件设置的任何教程吗? Please help, I'm completely confused. 请帮助,我完全困惑。

EDIT I seem to have been a bit unclear. 编辑我似乎还不清楚。 I'm going to use node.js to make games/apps with logins. 我将使用node.js通过登录制作游戏/应用。 When you "login" you automatically login to the server also. 当您“登录”时,您也会自动登录到服务器。 Not only from "work to home", I meant completely public as a multiplayer game. 不仅是从“工作到家”,我还意味着完全可以作为多人游戏公开。

One easy way to setup a node server for free is using AWS Free Tier. 免费设置节点服务器的一种简单方法是使用AWS Free Tier。

Once you follow that link and setup a server... 一旦您点击该链接并设置服务器...

You can follow along with this tutorial to get your server up and going, install node, install mongodb and even make an app that will run on the live server. 您可以按照本教程进行操作,以启动和运行服务器,安装节点,安装mongodb甚至制作将在实时服务器上运行的应用程序。

Run throgh this tutorial 通过本教程运行

How I installed node on my server, 我如何在服务器上安装节点,

Personally I have a VPS from Bluehost. 我个人有Bluehost的VPS This cost me about $120 a month but lets me do whatever I want with my server. 这每月花费约120美元,但我可以使用服务器做任何我想做的事情。 By whatever I want I mean install whatever I want... 我想要的就是安装我想要的...

I have npm install, I installed node.js globally. 我有npm install,我全局安装了node.js。 I installed mongoDB. 我安装了mongoDB。

I can run mongodb applications from anywhere and connect them to the MongoDB running on my server. 我可以在任何地方运行mongodb应用程序,并将它们连接到服务器上运行的MongoDB。

Having a VPS can come in handy as you can see... I suggest AWS free tier. 如您所见,拥有VPS可以派上用场...我建议使用AWS免费套餐。 Learn how to install all the things you want. 了解如何安装所需的所有东西。 Play with it. 玩吧。 Break it and start over. 打破它,重新开始。

But when your done with all of that... Be a Jedi Master! 但是当您完成所有这些工作后...成为绝地大师!

Node doesn't have any specific hardware requirements or configuration. 节点没有任何特定的硬件要求或配置。 And can be hosted on anything. 并且可以托管在任何东西上。

I guess you don't have a dedicated ip address. 我想您没有专用的IP地址。 So, your question seems to be all about network, routing and dealing with NAT. 因此,您的问题似乎全都与网络,路由和NAT处理有关。 If you're not familiar with those, it might be not a bad idea to use external hosting. 如果您不熟悉这些,使用外部托管可能不是一个坏主意。

But if you want to give it a try, this might be helpful - https://superuser.com/questions/121435/is-it-possible-to-host-a-web-server-from-behind-a-nat 但是,如果您想尝试一下,这可能会有所帮助-https: //superuser.com/questions/121435/is-it-possible-to-host-a-web-server-from-behind-a-nat

Besides hosting your own hardware, there are 2 options for what you describe. 除了托管自己的硬件外,您还可以使用2个选项进行描述。

One, use a portforwarding tool to make your home server accessible from your work, for example ngrok . 第一,使用portforwarding工具使您的家庭服务器可以通过工作访问,例如ngrok

Two, deploy your node.js app to an online platform, for example OpenShift or Heroku . 二,将您的node.js应用程序部署到一个在线平台,例如OpenShiftHeroku Most of these platforms have a low-performance free options. 这些平台大多数都具有低性能的免费选项。

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

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