华为云服务器 443 端口 ssl 无法使用问题排查

Author Avatar
呃哦 3月 08, 2021

需求

想部署个服务,解析个三级域名,但是不想去备案,随便在 cloud flare 上解析域名到服务器上,再用 certbot 申请个免费证书,走 ssl 避开备案检测。

日志报错

$ curl -v https://notify.eoyohe.xyz:443/ping
*   Trying 121.37.13.123...
* TCP_NODELAY set
* Connected to notify.eoyohe.xyz (121.37.13.123) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* error:1400410B:SSL routines:CONNECT_CR_SRVR_HELLO:wrong version number
* Closing connection 0
curl: (35) error:1400410B:SSL routines:CONNECT_CR_SRVR_HELLO:wrong version number

排查方式

查资料

Nginx upstream to https host - ssl3_get_record:wrong version number

Trying to access it by HTTPS will usually result in a HTTP error response by the server which, when interpreted as the expected TLS handshake response, will result in strange error messages like ssl3_get_record:wrong version number.

也就是说在 http 的接口上进行 https 访问,会得到类似的报错

排查机器上 443 端口占用

  1. nginx 修改为 listen 4443;
  2. lsof -i :443 可以看到已经没有监听中的端口

排查配置问题

同上,修改为 4443 端口后,发现可以访问,https://host:4443/ping 是可以访问的

排查 nginx 版本问题

# 下载最新版 nginx 源码
$ wget http://nginx.org/download/nginx-1.18.0.tar.gz
# 解压并编译
$ tar zxf nginx-1.18.0.tar.gz
$ cd nginx-1.18.0
# ssl 模块是必须的,其他模块暂时不知道,可能 gzip 也要
$ ./configure --prefix=/usr/local/nginx --with-http_ssl_module
$ make && make install
# 复制之前的配置文件并启动编译的nginx
$ nginx -s start
$ nginx -s reload
$ nginx -s stop

结果一样有该问题

怀疑是未备案被云供应商拦截了

  1. 搜索 V 站发现很多人被套路云拦截了,但我是华为云
  2. 提交工单询问华为云,不承认,不认同是被拦截

解决

用另一个在 良心云 备案过的域名解析到该服务器上,测试 443 端口可以走。

疑点

  • 服务器上 curl 是通的,外网 curl 不通,说明外网情况下可能确实被华为云拦截了