Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Xray(M+H+K+G+B+A)+Nginx配置中可通过CDN的协议,不能通过cloudfront分配的域名作为服务器地址。(cloudflare正常) #251

Answered by lxhao61
i-Eureka asked this question in Q&A
Discussion options

问题描述:xray 客户端服务器地址设置为 cloudfront 分配的地址,SNI设置为 h3a.example.com 时:tls:handshake failure.
当 xray 客户端服务器地址设置为 h3a.example.com(或设置为 cloudflare 域名)连接正常。
复现步骤:根据 Xray(M+H+K+G+B+A)+Nginx 配置(以下域名按配置中的域名示例)
将 h3a.example.com 分配到 cloudfront 具体配置如下图:
image
image
image
image
image
当我直接访问 cloudfront 分配的地址时,它访问的页面是 cdn.example.com,而非 h3a.example.com。
有办法解决吗?

You must be logged in to vote

基本了解你 Cloudfront CDN 流量中转设置有问题!
你需要按照如下方法解决:
1.若服务器使用 Cloudfront 上 VPS 关联示例 ID,否则关联外部源域名(直连 h3a.example.com),然后一步步正确配置即可。
2.然后修改原 cdn.example.com 关联的 A/AAA 记录为 Cloudfront CDN 完成后生成的 CNAM 记录。
3.最后更加详细及正确设置请参考网络上资料。

Replies: 5 comments 5 replies

Comment options

不明白你什么意思?h3a.example.com 为直连,无论由
Cloudflare 解析,还是 Cloudfront 解析,根本无需设置 CDN 流量中转。

You must be logged in to vote
2 replies
Comment options

那现在我把 cdn.example.com 使用 cloudfront 分配的域名(.cloudfront.net)来作为服务器地址,依旧连接失败。
下图示例:cft.nicename.tk=cdn.example.com,通过 cft CDN 分配的域名:dolniuwtol2mh.cloudfront.net=
.cloudfront.net。
image
image
cloudfront 和 cloudflare 不同,cloudflare 只需要打开云朵即可给站点启用 CDN,cloudfront 会分配一个 *.cloudfront.net 的域名来通过 CDN,而不能直接使用原域名。

Comment options

配置说明中:#1、本示例使用 REALITY Vision 配置(h3a.example.com)、CDN 流量中转(cdn.example.com) 来避免被封。https://github.com/lxhao61/integrated-examples/blob/bb6ae80cfcf597cb866bedb6015f3638090044f2/Xray(M%2BH%2BK%2BG%2BB%2BA)%2BNginx/2_nginx.conf#L137C1-L137C63
简明扼要,这里的 CDN 能否使用 cloudfront 的 cdn?我现在使用了 cloudfront,并不能连接到服务器,使用 cloudflare 没有问题。

Comment options

基本了解你 Cloudfront CDN 流量中转设置有问题!
你需要按照如下方法解决:
1.若服务器使用 Cloudfront 上 VPS 关联示例 ID,否则关联外部源域名(直连 h3a.example.com),然后一步步正确配置即可。
2.然后修改原 cdn.example.com 关联的 A/AAA 记录为 Cloudfront CDN 完成后生成的 CNAM 记录。
3.最后更加详细及正确设置请参考网络上资料。

You must be logged in to vote
2 replies
Comment options

很抱歉我还是没能找到解决方法,如果可以希望你能帮忙测试一下Cloudfront的使用。不过根据测试,问题确实出现在Cloudfront上,使用关联CNAM记录的域名和直接使用cft地址是一样的错误,但我认为托管CNAM记录和直接使用cft提供的域名本就是应该是一样的结果,毕竟回源正常呀。就像在使用cf时,服务器地址不一定要填自己的域名。
image
客户端如上配置时(已测试SNI为任何域名时,数据都无法传出:nginx和xray都没有访问日志)nginx访问日志看起来流量没有被转发。
image
当客户端按如下配置时(cf)一切正常
image
nginx访问日志
image

Comment options

源站和 cft 对应关系,测试回源没问题,访问 123456a.cloudfront.net 可以正常加载 cdn.example.com 的站点
image

Answer selected by lxhao61
Comment options

cft关键设置如下,此贴终结。引用XTLS/Xray-core#4501 (comment)
image

You must be logged in to vote
0 replies
Comment options

nginx server字段有ssl_reject_handshake on;CFT需要设置referer header回源。
image

You must be logged in to vote
0 replies
Comment options

组合是不是要更新一下了呢?

Oct 18 10:15:19 A2nd xray[1479]: 2025年10月18日 10:15:19.217333 [Warning] common/errors: This feature gRPC transport (with unnecessary costs, etc.) is deprecated and being migrated to XHTTP stream-up H2. Please update your config(s) according to release note and documentation before removal.

Oct 18 10:15:19 A2nd xray[1479]: 2025年10月18日 10:15:19.217366 [Warning] common/errors: This feature HTTPUpgrade transport (with ALPN http/1.1, etc.) is deprecated and being migrated to XHTTP H2 & H3. Please update your config(s) according to release note and documentation before removal.

You must be logged in to vote
1 reply
Comment options

组合己更新。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /