英文:
Node js express server on GCP VM giving SSL error
问题
我正在尝试访问托管在GCP上的express.js节点服务器,但出现以下错误:
此站点无法提供安全连接
<服务器IP>发送了无效的响应。
ERR_SSL_PROTOCOL_ERROR
我查看了另一个Stack Overflow答案,他们建议编辑网络选项卡中的default-allow-internal
以允许所有连接,我的网络选项卡现在如下所示:
我的服务器正常启动,我知道内部逻辑有效(它包含一个定时抓取器,每次运行时都会在控制台中记录,我可以看到它在那里成功运行),但我无法通过其外部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
<server ip> 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:
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://<ip>:8000
答案1
得分: 2
根据 @Zac Anger 的建议,最简单的选项是在您的服务器上使用负载均衡器来终止 SSL。
根据文档提供的信息:
> HTTP(S) 负载均衡可以在多个后端实例和多个地区之间平衡 HTTP 和 HTTPS 流量。您的整个应用程序可以通过单一的全球 IP 地址访问,从而简化了 DNS 设置。HTTP(S) 负载均衡可扩展,具有容错能力,无需预热,并支持基于内容的负载均衡。对于 HTTPS 流量,它提供了 SSL 终止和负载均衡。
要终止 SSL,请按照以下步骤操作:
-
创建一个至少具有 1 个运行实例的实例组。
-
创建以下内容的 HTTP 负载均衡器:
-
上传 SSL 证书。
-
创建一个后端服务,指向实例组。确保协议为 HTTP。
-
创建一个目标 HTTPS 代理,使用您上传的证书。
-
最后,创建一个全局转发规则,将 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:
-
Create an instance group that has at least 1 live instance.
-
Create http load balancer with the following:
-
Upload a SSL certificate.
-
Create a backend service to point to the instance group. Make sure the protocol is HTTP.
-
Create a target https proxy with the certificate you uploaded.
-
Finally, create a global forwarding rule that points HTTPS to the target proxy you created before.
-
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论