简体   繁体   English

将节点 js 服务器(在弹性 beanstalk AWS 上)url 更改为 HTTPS

[英]Change Node js server (on elastic beanstalk AWS) url to HTTPS

I am trying to deploy my React js app using an AWS s3 bucket.我正在尝试使用 AWS s3 存储桶部署我的 React js 应用程序。 However, I am fairly new to AWS and am having quite a difficult time.但是,我对 AWS 还很陌生,并且过得很艰难。 This react app communicates with a node / express server, which is hosted on an elastic beanstalk environment.这个反应应用程序与一个节点/快速服务器通信,该服务器托管在弹性 beanstalk 环境中。 I previously had the following error:我以前有以下错误:

Mixed Content: The page at 'https://myReactApp.s3.amazonaws.com/index.html' was loaded over HTTPS, but requested an insecure resource 'http://myElasticBeanstalkServer.us-east-1.elasticbeanstalk.com/signIn?username=lsharon&password=test4321'. This request has been blocked; the content must be served over HTTPS.

I began the process of trying to figure out how to "convert" my EB url into HTTPS.我开始尝试弄清楚如何将我的 EB url“转换”为 HTTPS。 I found lots of information about obtaining an ssl certificate.我发现了很多关于获得 ssl 证书的信息。 I am pretty confused on the whole process.我对整个过程很困惑。 Here is what I did:这是我所做的:

  1. I do have a domain name, registered through google domains.我确实有一个域名,通过谷歌域名注册。 I used it to obtain an ssl certificate.我用它来获得 ssl 证书。 My ssl certificate is verified through the AWS certificate manager console.我的 ssl 证书已通过 AWS 证书管理器控制台进行验证。 However, I am a bit confused how this relates to my node server which is hosted on elastic beanstalk.但是,我有点困惑这与托管在弹性 beantalk 上的节点服务器有何关系。 I connect to this API using the EB url...not my domain name.我使用 EB url 连接到这个 API ......不是我的域名。 How can I use my ssl certificate to secure my server url?如何使用我的 ssl 证书来保护我的服务器 url?
  2. I did find a little info about creating a hosted zone in Route 53, as well as adding 443 ports on the load balancer in my elastic beanstalk environment.我确实找到了一些关于在 Route 53 中创建托管区域以及在我的弹性 beanstalk 环境中的负载均衡器上添加 443 端口的信息。 However, I got lost pretty quickly.然而,我很快就迷路了。 Do I just use a 443 listener in the EB environment, or do I also need a 443 process?我是在EB环境中只使用443监听,还是我也需要443进程? Could someone explain this to me?有人可以向我解释一下吗? Also, relating to the Route 53 hosted zone, do I create the hosted zone using my domain name, or my API (elastic beanstalk) url?另外,关于 Route 53 托管区域,我是使用我的域名还是我的 API(弹性 beanstalk)url 创建托管区域? And when I create an alias, where do I route the traffic to?当我创建别名时,我应该将流量路由到哪里? My domain name, my EB url, or my s3 bucket?我的域名,我的 EB url,还是我的 s3 存储桶?

Currently, when I load my static web page in the browser, it renders fine and says secure.目前,当我在浏览器中加载我的 static web 页面时,它呈现良好并显示安全。 However, when I click one of my buttons (therefore sending a fetch request to my EB url), it ALSO works but changes to insecure and says my ssl is insecure.但是,当我单击其中一个按钮(因此向我的 EB url 发送获取请求)时,它也可以工作,但会更改为不安全,并说我的 ssl 不安全。

I do apologize for all the questions.我为所有的问题道歉。 I just feel rather lost and seem to be finding lots of information but can't seem to make it work quite right.我只是觉得很迷茫,似乎找到了很多信息,但似乎无法让它正常工作。 If anyone could help me out, I sure would appreciate it.如果有人可以帮助我,我肯定会很感激。

To answer your first question, you have to setup DNS somewhere, either in your Google Domains account or in Route53 depending on who you want to use as your DNS host, pointing the domain name to the load balancer.要回答您的第一个问题,您必须在某处设置 DNS,无论是在您的 Google Domains 帐户中还是在 Route53 中,具体取决于您希望将谁用作 DNS 主机,将域名指向负载均衡器。

I connect to this API using the EB url...not my domain name.我使用 EB url 连接到这个 API ......不是我的域名。 How can I use my ssl certificate to secure my server url?如何使用我的 ssl 证书来保护我的服务器 url?

You have to change your front-end application to use the domain that matches the SSL certificate when making API calls (and also use https instead of http for those API calls). You have to change your front-end application to use the domain that matches the SSL certificate when making API calls (and also use https instead of http for those API calls). There is no other option if you want the web browser to stop complaining about these security issues.如果您希望 web 浏览器停止抱怨这些安全问题,没有其他选择。

To answer your second question, SSL certificates in AWS Certificate Manager can be attached to a load balancer which will handle terminating the SSL for you.要回答您的第二个问题,可以将 AWS Certificate Manager 中的 SSL 证书附加到负载均衡器,该负载均衡器将为您终止 SSL。 The load balancer can still communicate with the EC2 instance using non-encrypted HTTP.负载均衡器仍然可以使用未加密的 HTTP 与 EC2 实例通信。 So all you need to do is attach the SSL certificate to the port 443 listener in the load balancer.因此,您需要做的就是将 SSL 证书附加到负载均衡器中的端口 443 侦听器。

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

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