如何为 Google Cloud 运行 应用启用 HSTS?
How to enable HSTS for Google Cloud Run app?
我的 Google Cloud 运行 应用程序使用传统的 302 响应将 HTTP 请求重定向到 HTTPS。有没有办法让 Google Cloud 运行 使用 HSTS header?
我的应用堆栈是 express
。我试过 helmet.hsts()
但它不起作用。似乎 HTTP 请求在到达我的 express
应用程序之前会被 Google 代理重定向。
这是我的示例请求和响应:
* Rebuilt URL to: <URL>
* Trying 2001:4860:4802:36::35...
* TCP_NODELAY set
* Connected to <HOST> (2001:4860:4802:36::35) port 80 (#0)
> GET / HTTP/1.1
> Host: <HOST>
> User-Agent: curl/7.55.1
> Accept: */*
>
< HTTP/1.1 302 Found
< Location: <URL>
< X-Cloud-Trace-Context: e1f3dfe0e7bd604c447ca0c8f8c0ea5c
< Date: Thu, 24 Jun 2021 10:23:48 GMT
< Content-Type: text/html
< Server: Google Frontend
< Content-Length: 0
<
* Connection #0 to host <HOST> left intact
您无法自定义云 运行 built-in 代理。因此你不能添加你想要的 header 就像严格的传输安全 header.
但是,作为解决方法,您可以部署 HTTPS 负载平衡器并将云 运行 服务添加为 Serverless NEG backend. Then, you have to configure the HTTPS Load Balancer to add a custom header
我的 Google Cloud 运行 应用程序使用传统的 302 响应将 HTTP 请求重定向到 HTTPS。有没有办法让 Google Cloud 运行 使用 HSTS header?
我的应用堆栈是 express
。我试过 helmet.hsts()
但它不起作用。似乎 HTTP 请求在到达我的 express
应用程序之前会被 Google 代理重定向。
这是我的示例请求和响应:
* Rebuilt URL to: <URL>
* Trying 2001:4860:4802:36::35...
* TCP_NODELAY set
* Connected to <HOST> (2001:4860:4802:36::35) port 80 (#0)
> GET / HTTP/1.1
> Host: <HOST>
> User-Agent: curl/7.55.1
> Accept: */*
>
< HTTP/1.1 302 Found
< Location: <URL>
< X-Cloud-Trace-Context: e1f3dfe0e7bd604c447ca0c8f8c0ea5c
< Date: Thu, 24 Jun 2021 10:23:48 GMT
< Content-Type: text/html
< Server: Google Frontend
< Content-Length: 0
<
* Connection #0 to host <HOST> left intact
您无法自定义云 运行 built-in 代理。因此你不能添加你想要的 header 就像严格的传输安全 header.
但是,作为解决方法,您可以部署 HTTPS 负载平衡器并将云 运行 服务添加为 Serverless NEG backend. Then, you have to configure the HTTPS Load Balancer to add a custom header