Tailscale 搭建 derper, 使用 Nginx 反向代理遇到的坑: http: TLS handshake error from 172.40.0.1:44442: cert mismatch with hostname: "" 作者: Chuwen 时间: 2023-10-10 分类: 谈天说地 ## 序言 按照网上找到的教程,大部分都是让你这么配置 Nginx: ```nginx location / { proxy_pass https://127.0.0.1:3443; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } ``` 但是这样做你会发现根本访问不了,derper 也会报出如下错误: ![](https://cdn.nowtime.cc/2023/10/10/1996389015.png) cert mismatch with hostname(证书与主机名不匹配) **异常原因(这是我的个人猜测,欢迎 dalao 们指正):** 可能是在 Nginx 在与后端 TLS 握手期间,deper 进行了对 SSL 强校验,发现 hostname 和证书的主机名不匹配,则拒绝连接 ## 解决方案 ```nginx location / { proxy_pass https://127.0.0.1:3443; proxy_http_version 1.1; proxy_set_header Host $host; # 加上这 2 行配置即可解决 proxy_ssl_server_name on; proxy_ssl_name $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } ``` 如果访问你的 derper 地址,出现以下界面表示配置成功 ![](https://cdn.nowtime.cc/2023/10/10/4151549465.png) 标签: Tailscale