SparkLee commented on issue #10234:
URL: https://github.com/apache/apisix/issues/10234#issuecomment-1792632784
我今天遇到了同样的错误, 我是通过配置 `fallback_sni` 来解决的。
```
apisix
ssl:
fallback_sni: "${your sni}"
````
我遭遇这个错误的背景是这样的:
我们的 APP 由于遇到域名劫持的问题,所以使用了阿里云的 HttpDNS,但是因为 HttpDNS 直接使用 IP 而非域名的方式对 APISIX
服务器发起 HTTPS 请求,导致 APISIX 因为获取不到域名信息(SNI标识)而无法匹配相应的 SSL 证书,从而导致请求失败,并且在 APISIX 的
error 日志中记录如下错误:`http_ssl_phase(): failed to fetch ssl config: failed to find
SNI: please check if the client requests via IP or uses an outdated protocol`。
解决这个问题的思路是:
既然客户端 APP 无法提供 SNI 标识,那就配置一个默认的 SNI,亦即配置一个默认的 SSL 证书即可,配置示例:
`apisix.ssl.fallback_sni: "www.baidu.com"` 。
另外为了匹配 HTTPS + IP 的请求,在 APISIX Dashboard 后台配置的 APISIX 路由的 “域名” 需要是
IP,或者干脆留空,亦即匹配所有的请求域名与 IP。
最后,由于我们在 APISIX 后面还有一个 Nginx 的上游服务,由于 Nginx 服务也配置了多个 Server,每个 Server
配置为不同的域名,由于这种 HTTPS + IP 的请求方式,导致 APISIX 无法传递请求域名”给到上游 Nginx 服务,导致 Nginx
也无法区分到底应该用哪个 Server 来提供服务,所以此时还需要配置一个默认的 Nginx Server,比如:
```nginx.conf
server {
listen 80 default_server;
}
```
参考资料:
1、官方文档:[启用 SSL 证书后,为什么无法通过 HTTPS + IP
访问对应的路由?](https://apisix.apache.org/zh/docs/apisix/FAQ/#%E5%90%AF%E7%94%A8-ssl-%E8%AF%81%E4%B9%A6%E5%90%8E%E4%B8%BA%E4%BB%80%E4%B9%88%E6%97%A0%E6%B3%95%E9%80%9A%E8%BF%87-https--ip-%E8%AE%BF%E9%97%AE%E5%AF%B9%E5%BA%94%E7%9A%84%E8%B7%AF%E7%94%B1)
2、官方 APISIX
配置文件示例:[fallback_sni](https://github.com/apache/apisix/blob/release/3.6/conf/config-default.yaml#L122)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]