简体   繁体   English

如何使用服务器域名从本地计算机访问我的nodejs Web服务器?

[英]How can I access my nodejs web server from my local computer using the server domain name?

I installed nodejs and created a sample app. 我安装了nodejs并创建了一个示例应用程序。 When I run npm start I get a message saying that I can open my web browser to http://localhost:3000 to see the app in action, but this installation is on a web server - not my local computer, so, instead of localhost:3000 I want to get there using something like mydomain.com:3000 当我运行npm start我收到一条消息,说我可以打开Web浏览器到http:// localhost:3000来查看运行中的应用程序,但是此安装位于Web服务器上,而不是本地计算机上,因此,而不是localhost:3000我想使用mydomain.com:3000之类的东西到达那里

I can't find the answer, it's very likely I just don't know how to search for it... any ideas? 我找不到答案,很可能我就是不知道该怎么搜索...有什么想法吗?

I'm following the tutorial here: https://facebook.github.io/react/tutorial/tutorial.html 我在这里关注该教程: https : //facebook.github.io/react/tutorial/tutorial.html

I think I only needed to get away from this for a while. 我想我只需要暂时摆脱这种情况。 I got it working using ssh local forwarding. 我让它使用ssh本地转发工作。

I already used an ssh config file to log in to my server without having to remember the password, so I just added this line to my config file: 我已经使用ssh配置文件登录到服务器,而不必记住密码,因此我将以下行添加到了配置文件中:

LocalForward localhost:3000 xxx.xxx.xxx.xxx:3000

where xxx.xxx.xxx.xxx is my server IP address. 其中xxx.xxx.xxx.xxx是我的服务器IP地址。

Then, I connected to my server via ssh: 然后,我通过ssh连接到服务器:

ssh -f -N mysite

Once connected, I open up the browser and go to localhost:3000 and there it is now. 建立连接后,我打开浏览器并转到localhost:3000,现在就可以了。

I used my ssh config file, but it should also work without it. 我使用了ssh配置文件,但没有它也应该可以工作。

ssh -f -N -R 3000:localhost:3000 mydomain.com

I found this command that eventually led me to solve my problem in this link: http://stuff-things.net/2016/01/20/tunneling-to-localhost/ 我发现此命令最终使我解决了此链接中的问题: http : //stuff-things.net/2016/01/20/tunneling-to-localhost/

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

相关问题 如何在服务器的控制台中访问我的nodeJS应用程序? - How can I access to my nodeJS app in console on my server? 为什么我无法从 iOs 模拟器访问我的 nodejs 本地服务器 - Why I can't access my nodejs local server from iOs simulator 我可以使用可读地址而不是http://192.168.xx/访问本地NodeJS服务器吗 - Can I access my local NodeJS server with readable address instead of http://192.168.x.x/ 如何从我的 nodejs 服务器中删除文件 - How can i delete a file from my nodejs server 如何在nodejs中使用我的服务器域发送电子邮件 - how to send an email using my server's domain in nodejs 如何使用REST / JSON / GET / POST从我的节点服务器访问我的couchdb? - How can I access my couchdb from my node server using REST/JSON/GET/POST? 如何从我的服务器获取 img 请求的网站域名? - How to get web site domain name on img request from my server? 我的 Web 应用程序在尝试通过域名访问时不起作用,但如果我使用服务器的 IP 后跟一个端口,它就可以工作 - My web application does not work when trying to access it by the domain name, but it works if I use the server's IP followed by a port 使用nodejs为我的角应用程序的Web服务器 - web server using nodejs for my angular app 如何使用自定义域访问自己的ogar服务器? - How to access my own ogar server by using a custom domain?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM