Node.js Express服务器在GCP虚拟机上出现SSL错误。

huangapple go评论84阅读模式
英文:

Node js express server on GCP VM giving SSL error

问题

我正在尝试访问托管在GCP上的express.js节点服务器,但出现以下错误:

此站点无法提供安全连接
<服务器IP>发送了无效的响应。
ERR_SSL_PROTOCOL_ERROR

我查看了另一个Stack Overflow答案,他们建议编辑网络选项卡中的default-allow-internal以允许所有连接,我的网络选项卡现在如下所示:
Node.js Express服务器在GCP虚拟机上出现SSL错误。

我的服务器正常启动,我知道内部逻辑有效(它包含一个定时抓取器,每次运行时都会在控制台中记录,我可以看到它在那里成功运行),但我无法通过其外部IP地址访问它 https://<ip>:8000

英文:

I'm trying to access an express.js node server I'm hosting on GCP and I'm getting this error:

This site can’t provide a secure connection
&lt;server ip&gt; sent an invalid response.
ERR_SSL_PROTOCOL_ERROR

I looked at another stack overflow answer and they said to edit default-allow-internal in the network tab to allow all, my network tab looks like this now:
Node.js Express服务器在GCP虚拟机上出现SSL错误。

My server starts fine and I know the logic inside works (it contains a scraper that logs to the console every time it runs and I can see it's succeeding there) But I can't access it via it's external IP https://&lt;ip&gt;:8000

答案1

得分: 2

根据 @Zac Anger 的建议,最简单的选项是在您的服务器上使用负载均衡器来终止 SSL。

根据文档提供的信息:

> HTTP(S) 负载均衡可以在多个后端实例和多个地区之间平衡 HTTP 和 HTTPS 流量。您的整个应用程序可以通过单一的全球 IP 地址访问,从而简化了 DNS 设置。HTTP(S) 负载均衡可扩展,具有容错能力,无需预热,并支持基于内容的负载均衡。对于 HTTPS 流量,它提供了 SSL 终止和负载均衡。

要终止 SSL,请按照以下步骤操作:

  1. 创建一个至少具有 1 个运行实例的实例组。

  2. 创建以下内容的 HTTP 负载均衡器:

    1. 上传 SSL 证书。

    2. 创建一个后端服务,指向实例组。确保协议为 HTTP。

    3. 创建一个目标 HTTPS 代理,使用您上传的证书。

    4. 最后,创建一个全局转发规则,将 HTTPS 指向您之前创建的目标代理。

英文:

As @Zac Anger suggested the easiest option is to use Load Balancer for terminating SSL at your server.

As given in the document:

> HTTP(S) load balancing can balance HTTP and HTTPS traffic across
> multiple backend instances, across multiple regions. Your entire app
> is available via a single global IP address, resulting in a simplified
> DNS setup. HTTP(S) load balancing is scalable, fault-tolerant,
> requires no pre-warming, and enables content-based load balancing. For
> HTTPS traffic, it provides SSL termination and load balancing.

To terminate SSL follow the below steps:

  1. Create an instance group that has at least 1 live instance.

  2. Create http load balancer with the following:

    1. Upload a SSL certificate.

    2. Create a backend service to point to the instance group. Make sure the protocol is HTTP.

    3. Create a target https proxy with the certificate you uploaded.

    4. Finally, create a global forwarding rule that points HTTPS to the target proxy you created before.

huangapple
  • 本文由 发表于 2023年1月5日 08:20:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/75012684.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定