如何在 nginx 的 80 端口上的 https 上制作 aws public ip 运行

how to make aws public ip run on https on port 80 for nginx

我已经在 AWS EC2 上托管了我的 node.js 应用程序。

我的 nodejs 应用程序没有域名。我 运行 它位于 Public IPv4 地址 54.242.85.178

我的前端有一个域,它的 运行 在 https 上,所以当 https 和 http 出现时,我收到以下错误:

Mixed Content: The page at 'https://www.wixten.com/query/622c64b4a12ed5002313daf5' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://54.242.85.178/answersapi/622c64b4a12ed5002313daf5'. This request has been blocked; the content must be served over HTTPS.

错误说明了一切 - 您不能混合使用 https 和 http。您必须检查您的源代码并删除所有 http url 并将它们替换为正确的 https url。

根据错误,您的前端正在对 HTTP 端点(在 ip 54.242.85.178 上)进行 HTTPS 调用,因此出现该错误。我猜您正在使用 ajax 进行调用。

为了快速修复,您可以更新前端以对后端进行 HTTP 调用,这将解决此问题,但强烈不 推荐这样做但它会帮助您更好地理解问题。

理想情况下,您还必须在后端添加 SSL 证书,然后您可以从前端对其进行 HTTPS 调用。