最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

AWS Beanstalk单实例环境中的http到https url

IT培训 admin 6浏览 0评论

AWS Beanstalk单实例环境中的http到https url

我在NodeJS/Express上部署了AWS Beanstalk应用。当前配置是:

Environment type: single instance
EC2 instance type: t2.micro
Node.js version: 10.15.0
No load balancer
Proxy server : Nginx

[部署后,它给我一个URL http://<app-name>.<server-location>.elasticbeanstalk/

我使用URL-Postman测试(使用http://<app-name>.<server-location>.elasticbeanstalk/users/authenticate)我的身份验证API,它为我提供了200 OK的状态代码,并且运行正常。

当我使用HTTPS而不是HTTP时,它无法按预期方式工作。在邮递员中,我得到以下错误:

There was an error connecting to https://<app-name>.<server-location>.elasticbeanstalk/users/authenticate

我将前端部署在netlify上,当我从Web应用程序触发相同的请求时,它给我以下错误:

The page at 'https://<app-name>lify/login' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://<app-name>.<server-location>.elasticbeanstalk/users/authenticate'. This request has been blocked; the content must be served over HTTPS.

我了解,由于我的请求来自https,因此我需要将后端配置为具有https侦听器。我不确定如何在没有负载均衡器且我的env类型是单个实例的AWS Beanstalk中完成此操作。

我是AWS新手。感谢你的帮助。谢谢!

回答如下:

您需要将.ebextension配置文件添加到:

  • 允许您的安全组中的443通信
  • 安装ssl软件包
  • 将证书从应用程序包复制到ssl目录。 (可以在证书管理器中创建证书)或将其粘贴到配置文件中
  • 编辑nginx配置

这里是一个例子https://edwardsamuel.wordpress/2015/07/17/enable-https-and-http-redirect-on-aws-elastic-beanstalk/

AWS Beanstalk单实例环境中的http到https url

我在NodeJS/Express上部署了AWS Beanstalk应用。当前配置是:

Environment type: single instance
EC2 instance type: t2.micro
Node.js version: 10.15.0
No load balancer
Proxy server : Nginx

[部署后,它给我一个URL http://<app-name>.<server-location>.elasticbeanstalk/

我使用URL-Postman测试(使用http://<app-name>.<server-location>.elasticbeanstalk/users/authenticate)我的身份验证API,它为我提供了200 OK的状态代码,并且运行正常。

当我使用HTTPS而不是HTTP时,它无法按预期方式工作。在邮递员中,我得到以下错误:

There was an error connecting to https://<app-name>.<server-location>.elasticbeanstalk/users/authenticate

我将前端部署在netlify上,当我从Web应用程序触发相同的请求时,它给我以下错误:

The page at 'https://<app-name>lify/login' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://<app-name>.<server-location>.elasticbeanstalk/users/authenticate'. This request has been blocked; the content must be served over HTTPS.

我了解,由于我的请求来自https,因此我需要将后端配置为具有https侦听器。我不确定如何在没有负载均衡器且我的env类型是单个实例的AWS Beanstalk中完成此操作。

我是AWS新手。感谢你的帮助。谢谢!

回答如下:

您需要将.ebextension配置文件添加到:

  • 允许您的安全组中的443通信
  • 安装ssl软件包
  • 将证书从应用程序包复制到ssl目录。 (可以在证书管理器中创建证书)或将其粘贴到配置文件中
  • 编辑nginx配置

这里是一个例子https://edwardsamuel.wordpress/2015/07/17/enable-https-and-http-redirect-on-aws-elastic-beanstalk/

发布评论

评论列表 (0)

  1. 暂无评论