全球主机交流论坛

标题: nginx反代难题-套CF IP限制 [打印本页]

作者: llyang    时间: 2024-7-26 17:37
标题: nginx反代难题-套CF IP限制
一个小学的网站,练习反代发现始终无法成功。
网站地址如下

  1. fna.northerneducationtrust.org
复制代码


需要UK IP访问。如果是UK IP,访问十分正常,没有验证等。

我的VPS选用的UK IP,用这个IP代理可以访问该网站。

已经使用这些方法都无效
proxy_redirect on/off;
proxy_ssl_server_name on;

反代不成功的截图如下


作者: Crownsecular    时间: 2024-7-26 17:43
location / {
        proxy_pass http://fna.northerneducationtrust.org;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Port $server_port;
    }
作者: MrJoker    时间: 2024-7-26 18:03
签名用edgecdn完美解决
作者: 职业菜鸟    时间: 2024-7-26 18:14
是不是反代的时候 传递真实IP 给 它了
作者: iks    时间: 2024-7-26 18:56
你不发
ssl_name $Host;
吗?
作者: llyang    时间: 2024-7-26 21:10
Crownsecular 发表于 2024-7-26 17:43
location / {
        proxy_pass http://fna.northerneducationtrust.org;
        proxy_set_header Host ...

直接报告:ERR_TOO_MANY_REDIRECTS
添加proxy_redirect off;也一样
作者: xfspace    时间: 2024-7-26 22:35


你加x-forward x-real不正告诉对面你用反代访问

作者: llyang    时间: 2024-7-26 22:42
xfspace 发表于 2024-7-26 22:35
你加x-forward x-real不正告诉对面你用反代访问

X-Real-IP
X-Forwarded-For
注释与开启,表现一样
作者: llyang    时间: 2024-7-26 23:01
本帖最后由 llyang 于 2024-7-26 23:03 编辑

nginx报错如下:


  1. 2024/07/26 14:59:16 [error] 43597#43597: *22 connect() to [2606:xxxx:3034::ac43:be1e]:443 failed (101: Network is unreachable) while connecting to upstream, client: 172.167.88.51, server: www.mydomain.com, request: "GET / HTTP/2.0", upstream: "https://[2606:xxxx:3034::ac43:be1e]:443/", host: "www.mydomain.com"

  2. 2024/07/26 14:59:17 [error] 43597#43597: *22 connect() to [2606:xxxx:3031::6815:2189]:443 failed (101: Network is unreachable) while connecting to upstream, client: 172.167.88.51, server: www.mydomain.com, request: "GET /cdn-cgi/challenge-platform/h/g/orchestrate/chl_page/v1?ray=8a9540b07f3a3634 HTTP/2.0", upstream: "https://[2606:xxxx:3031::6815:2189]:443/cdn-cgi/challenge-platform/h/g/orchestrate/chl_page/v1?ray=8a9540b07f3a3634", host: "www.mydomain.com", referrer: "https://www.mydomain.com/?__cf_chl_rt_tk=CN_qBOKFGQHcehplHm5VTXmY7VFB8N9Hcn34eu3pt40-1722005957-0.0.1.1-4330"
复制代码


关闭IPv6也没用
作者: Tonylee    时间: 2024-7-27 11:30
反代 问题 ,解决了吗???
作者: swan    时间: 2024-7-27 11:36
proxy_set_header Host fna.northerneducationtrust.org
作者: llyang    时间: 2024-7-27 16:18
swan 发表于 2024-7-27 11:36
proxy_set_header Host fna.northerneducationtrust.org


proxy_set_header Host fna.northerneducationtrust.org;
OR
proxy_set_header $host;

都不行,常用的都测试了
作者: llyang    时间: 2024-7-27 16:47
本帖最后由 llyang 于 2024-7-27 16:48 编辑

把我测试过的一些代码发出来.remark部分是我测试过不行的

  1.      proxy_pass https://fna.northerneducationtrust.org;
  2. #    proxy_pass http://fna.northerneducationtrust.org;
  3.      proxy_set_header Host fna.northerneducationtrust.org;
  4. #    proxy_ssl_name $host;
  5.      proxy_ssl_name fna.northerneducationtrust.org;
  6.     proxy_ssl_server_name on;
  7. #    proxy_set_header X-Real-IP $remote_addr;
  8. #    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  9.      proxy_set_header X-Forwarded-Proto $scheme; #ERR_TOO_MANY_REDIRECTS

  10.      proxy_set_header Accept-Encoding "";
  11.      sub_filter fna.northerneducationtrust.org mydomain.com;
  12. #    proxy_redirect https://fna.northerneducationtrust.org https://mydomain.com;
  13. #    proxy_redirect off;
  14. #    sub_filter 'abc'  '123'  ;
  15. #    sub_filter_once off;
复制代码

作者: Showfom    时间: 2024-7-27 17:14
正好没事做,帮你修好了,亲测有效,记得要用 UK 的 IP,再不行的话你换个别的 UK 商家的 IP 试试,也可能是访问量大以后触发了对面 CF 设置的 WAF


  1.         location / {
  2.             proxy_pass https://fna.northerneducationtrust.org;
  3.             proxy_redirect off;
  4.             proxy_set_header Host fna.northerneducationtrust.org;
  5.             proxy_set_header Accept-Encoding '';
  6.          
  7.             client_max_body_size    10m;
  8.             client_body_buffer_size  512k;

  9.             proxy_connect_timeout    5;
  10.             proxy_read_timeout       60;
  11.             proxy_send_timeout       5;
  12.             proxy_buffer_size        16k;
  13.             proxy_buffers            4 64k;
  14.             proxy_busy_buffers_size 128k;

  15.             proxy_hide_header Alt-Svc;
  16.             proxy_hide_header Cf-Cache-Status;
  17.             proxy_hide_header Report-To;
  18.             proxy_hide_header Nel;
  19.             proxy_hide_header Cf-Ray;
  20.             proxy_hide_header Vary;
  21.             proxy_hide_header X-protocol;
  22.             proxy_hide_header Strict-Transport-Security;
  23.             proxy_hide_header X-Frame-Options;
  24.             proxy_hide_header X-Content-Type-Options;
  25.             proxy_hide_header X-XSS-Protection;

  26.             proxy_ssl_server_name on;

  27.             sub_filter 'fna.northerneducationtrust.org' '你的域名';
  28.             sub_filter_once off;
  29.             sub_filter_types text/javascript application/json application/ld+json application/xml;
  30.         }
复制代码

作者: llyang    时间: 2024-7-27 19:33
Showfom 发表于 2024-7-27 17:14
正好没事做,帮你修好了,亲测有效,记得要用 UK 的 IP,再不行的话你换个别的 UK 商家的 IP 试试,也可能 ...

了不起,可以正常工作了,万分感谢

有个小插曲,以前的UK IP无论咋样都不行;新换一个UK IP+复制你的代码,妥妥的
作者: xiaotangke    时间: 2024-7-27 22:17
llyang 发表于 2024-7-26 21:10
直接报告:ERR_TOO_MANY_REDIRECTS
添加proxy_redirect off;也一样

解决了吗?
作者: xiaotangke    时间: 2024-7-27 22:19
Showfom 发表于 2024-7-27 17:14
正好没事做,帮你修好了,亲测有效,记得要用 UK 的 IP,再不行的话你换个别的 UK 商家的 IP 试试,也可能 ...

哇塞 给力啊
请教个问题,反向代理 能否开启QUIC ?
作者: myoppo    时间: 2024-7-28 08:40
llyang 发表于 2024-7-27 19:33
了不起,可以正常工作了,万分感谢

有个小插曲,以前的UK IP无论咋样都不行;新换一个UK IP+复制你 ...

估计网站设置有 IP 速率限制等策略

不知道新 IP 访问量一大会不会在触发
作者: xu81709752    时间: 2024-8-5 06:52
Showfom 发表于 2024-7-27 17:14
正好没事做,帮你修好了,亲测有效,记得要用 UK 的 IP,再不行的话你换个别的 UK 商家的 IP 试试,也可能 ...

老板 这个cf js challange 卡住怎么半




欢迎光临 全球主机交流论坛 (https://443502.xyz/) Powered by Discuz! X3.4