node.js - 为什么我可以访问我的网站(IP地址):port but not (domain name):port?

标签 node.js apache amazon-ec2 port cloudflare

我有一个使用弹性 IP 12.34.56.78 运行的 Amazon EC2 实例。我拥有一个域名 example.com,我已将其设置为指向 EC2 实例。我在 EC2 实例的端口 80 上运行 Apache Web 服务器,当我访问 http://12.34.56.78 和 http://example.com 时,我可以看到该网站。

我还在端口3000上运行node.js服务器。当我访问http://12.34.56.78:3000时我可以看到nodejs页面,但当我访问http://example.com:3000时看不到nodejs页面。我的 EC2 实例的安全组允许端口 80、443 和 3000 上的 TCP/UDP。为什么当我通过域名访问我的网站时看不到我的 node.js 页面? (我想运行一台 Apache 服务器和一台 Node.js 服务器)

我认为我遇到此问题是因为我使用 cloudflare 将 http://example.com 与 12.34.56.78 链接。但即使当我尝试连接 http://direct.example.com:3000 时,我也看不到我的 node.js 服务器。 (直接子域应该直接转到 12.34.56.78,cloudflare 不做任何工作)

有什么想法吗?

最佳答案

你不能,因为如果你通过单击 cloud-image 通过 cloudflare 传递你的域名,你的端口将只能像这样使用:

对于通过 HTTP 发出的请求(CloudFlare 上的所有域):

80 8080 8880 2052 2082 2086 2095

对于通过 HTTPS 发出的请求(仅限订阅 Pro、Business 或 Enterprise 的域):

443 2053 2083 2087 2096 8443

我的解决方案是为 ssh、python 等任何实例创建一个不通过 cloudflare 的子域。

https://support.cloudflare.com/hc/en-us/articles/200169156-Which-ports-will-CloudFlare-work-with-

关于node.js - 为什么我可以访问我的网站(IP地址):port but not (domain name):port?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20876321/

相关文章:

javascript - 在不会永远运行的脚本中关闭 Mongoose 连接

javascript - nodemailer 无法在本地主机或云上工作?

macos - 如何在 OSX 中将 Dropbox 目录用作虚拟主机文档根目录?

apache - 当我发布新版本的网站时,为什么我的用户看不到最新更新?

amazon-web-services - 如何获取 Amazon EC2 Spot 实例中断率

javascript - 对 API 的 JSON 数据的跨源请求 - "You may need an appropriate loader to handle this file type."

node.js - 为什么在文件名中包含哈希比将时间戳附加为查询参数更适合缓存?

php - 如何解决 CentOS7、Apache 和 php 脚本中的用户权限问题

java - 在 AWS EC2 上部署 Web 应用程序

django - 直接上传到 S3 还是通过 EC2?