数字海洋上的访问节点应用程序

编程入门 行业动态 更新时间:2024-10-15 20:17:29
本文介绍了数字海洋上的访问节点应用程序 - 无法访问此网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我无法访问我的数字海洋节点js应用程序。我已经SSH'ed,从Git克隆我的Node应用程序,已安装npm,并成功启动了应用程序的液滴,但我得到错误

此网站无法访问

Digital Ocean文档说,只需转到<您的网站的ip>:< port> ,即可访问您面向公众的网站:

我通过转到 67.205.185.63:9000 / (我的应用程序在9000端口上运行,如您所见):

root @ nodejs-512mb-nyc1-01:〜/ demos#npm start

live-demos@1.0.0 start / root / demos

节点app.js

演示正在监听端口9000

如何访问我的节点应用程序?

var express = require('express'); var bodyParser = require('body-parser'); var app = express(); var port = process.env.PORT || 9000; $ b app.listen(port,function(){ console.log('Demos正在监听端口'+ port); });

解决方案

一些数字海洋飞沫(主要是一键式应用程序)随ufw防火墙一起安装,默认情况下所有端口除22,80,和443被阻止。

检查ufw是否安装以及哪些端口被阻止/打开:

sudo ufw status

输出:

执行从 - ------ ---- 22 LIMIT Anywhere 80 ALLOW Anywhere $ b $ (v6) 80(v6)允许任何地方(v6) 443(v6)允许任何地点这里(v6)

允许在端口9000上执行流量操作:

sudo ufw允许9000 / tcp

I am unable to access my digital ocean node js app. I've already SSH'ed in, cloned my Node app from Git, npm installed, and successfully started the app on the droplet, yet I get error

This site can't be reached

Digital Ocean docs say you can access your publicly facing website simply by going to <your website's ip>:<port>:

I did this by going to 67.205.185.63:9000/ (my app is running on port 9000 as you can see):

root@nodejs-512mb-nyc1-01:~/demos# npm start

live-demos@1.0.0 start /root/demos

node app.js

Demos is listening on port 9000

How else should I be accessing my node app?

var express = require('express'); var bodyParser = require('body-parser'); var app = express(); var port = process.env.PORT || 9000; ... app.listen(port, function () { console.log('Demos is listening on port ' + port); });

解决方案

Some Digital Ocean droplets (mainly one-click apps) come with ufw firewall installed and by default all ports except for 22, 80, and 443 are blocked.

To check if ufw is installed and which ports are blocked/open do:

sudo ufw status

Output:

To Action From -- ------ ---- 22 LIMIT Anywhere 80 ALLOW Anywhere 443 ALLOW Anywhere 22 (v6) LIMIT Anywhere (v6) 80 (v6) ALLOW Anywhere (v6) 443 (v6) ALLOW Anywhere (v6)

To allow traffic on port 9000 do:

sudo ufw allow 9000/tcp

更多推荐

数字海洋上的访问节点应用程序

本文发布于:2023-10-28 04:07:52,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:节点   应用程序   海洋   数字

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!