[英]How do I find the IPv4 address on a Google Cloud service?
I have a Go service, deployed on Heroku, which pulls the IPv4 address from the request header successfully.我有一个 Go 服务,部署在 Heroku 上,它成功地从请求 header 中提取了 IPv4 地址。
ip := net.ParseIP(strings.Split(r.Header.Get("X-Forwarded-For"), ",")[0]).String()
I have deployed the identical code as a service to Google Cloud, and the IP addresses are frequently IPv6 in about 25% of the time.我已将相同的代码作为服务部署到 Google Cloud,IP 地址通常在大约 25% 的时间内是 IPv6。 After examining the full Request Header, there is no IPv4 address available anywhere, only IPv6.
在检查完整的请求 Header 后,没有任何可用的 IPv4 地址,只有 IPv6。
Heroku's Request Header X-Forwarded-For ALWAYS contains the IPv4 address, yet Google Cloud doesn't. Heroku 的请求 Header X-Forwarded-For 始终包含 IPv4 地址,但 Google Cloud 不包含。 Does anyone know a way to force the IPv4 format for Request Headers in Google Cloud?
有谁知道在谷歌云中为请求标头强制使用 IPv4 格式的方法?
Clients can connect via IPv4 or IPv6 but not both.客户端可以通过 IPv4 或 IPv6 连接,但不能同时连接。 Only one address family will be used by the client and only one IP address will be recorded by the proxy.
客户端只会使用一个地址族,代理只会记录一个 IP 地址。
Additional information:附加信息:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.