简体   繁体   English

Cloudfront 分发不适用于 EC2 实例

[英]Cloudfront distribution does not work with for an EC2 instance

I'm using an EC2 instance (AWS) to run my server.我正在使用 EC2 实例 (AWS) 来运行我的服务器。 I've been testing out a few things and want my website and server domains to be HTTPS for a cookie related issue.我一直在测试一些东西,并希望我的网站和服务器域为 HTTPS 以解决 cookie 相关问题。 I was able to add my website (hosted on S3 as of now) on cloudfront to get a secure domain.我能够在云端添加我的网站(目前托管在 S3 上)以获得安全域。 I tried to do the same with my server URL.我尝试对我的服务器 URL 做同样的事情。 However My server is not working on the new Cloudfront URL.但是,我的服务器无法在新的 Cloudfront URL 上运行。 I have my webapp on Cloudfront and It's working completely fine on the new generated cloudfront URL.我在 Cloudfront 上有我的 webapp,它在新生成的 cloudfront URL 上运行良好。

Details:细节:

  1. I have added the public IPv4 DNS to Cloudfront's origin Domain Name.我已将公共 IPv4 DNS 添加到 Cloudfront 的源域名。
  2. The running server is a Node Server.运行服务器是节点服务器。 So I try to access it by d7xxxxxxxxx.cloudfront.net:3001 (server is running on port 3001).所以我尝试通过 d7xxxxxxxxx.cloudfront.net:3001 访问它(服务器在端口 3001 上运行)。 (But does not respond) (但没有回应)
  3. The security group is configured with all ports open.安全组配置为打开所有端口。 (So this should not be a problem I guess.) (所以我猜这应该不是问题。)

Questions问题

  1. How can I get my server to work on Cloudfront?如何让我的服务器在 Cloudfront 上运行? The URL is not responding. URL 没有响应。 (The server is working when I access it by the EC2 public DNS). (当我通过 EC2 公共 DNS 访问它时,服务器正在工作)。
  2. Is it fine to use the public DNS of the ec2 to connect it to cloudfront on temporary basis?使用ec2的公共DNS临时连接到云端可以吗?

References参考

  1. Ref参考

So I try to access it by d7xxxxxxxxx.cloudfront.net:3001 (server is running on port 3001)所以我尝试通过 d7xxxxxxxxx.cloudfront.net:3001 访问它(服务器在端口 3001 上运行)

You would only access the CloudFront distribution at ports 80 and 443 .您只能在端口80443访问 CloudFront 分配。 CloudFront doesn't mirror the ports of the origin server, it only serves the default ports for HTTP and HTTPS. CloudFront 不镜像源服务器的端口,它只为 HTTP 和 HTTPS 提供默认端口。 You would configure port 3001 in your origin settings within CloudFront as the origin HTTP port.您可以在 CloudFront 的源设置中将端口 3001 配置为源 HTTP 端口。

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

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