Update nginx.conf
Browse files- nginx.conf +28 -35
nginx.conf
CHANGED
@@ -9,58 +9,51 @@ server {
|
|
9 |
scgi_temp_path /tmp/scgi_temp 1 2;
|
10 |
|
11 |
access_log /dev/stdout;
|
12 |
-
error_log /dev/stderr info;
|
13 |
|
14 |
location / {
|
15 |
-
|
16 |
-
proxy_pass https://chatgpt.com;
|
17 |
|
18 |
-
#
|
19 |
-
proxy_set_header Host
|
20 |
-
|
21 |
-
# --- 保持之前成功的头部伪装 ---
|
22 |
proxy_set_header X-Real-IP $remote_addr;
|
23 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
24 |
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
|
25 |
proxy_set_header User-Agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36";
|
|
|
|
|
26 |
proxy_set_header Accept "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9";
|
27 |
-
proxy_set_header Accept-Language "en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7";
|
|
|
|
|
|
|
|
|
28 |
proxy_set_header Accept-Encoding "";
|
29 |
-
|
30 |
-
proxy_set_header
|
31 |
-
|
|
|
|
|
|
|
|
|
32 |
|
33 |
proxy_buffering off;
|
34 |
|
35 |
proxy_ssl_server_name on;
|
36 |
proxy_ssl_protocols TLSv1.2 TLSv1.3;
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
# 这些规则可能需要根据实际观察到的 Location 和 Set-Cookie 头进行调整
|
41 |
-
|
42 |
-
# 主要规则:捕获以 https://(可能的子域名.)chatgpt.com 开头的 Location 头
|
43 |
-
proxy_redirect ~^https://([a-zA-Z0-9\-]+\.)*chatgpt\.com(?<path>.*)$ https://$host${path};
|
44 |
-
# 备用:捕获以 http 开头的 (不太可能,但以防万一)
|
45 |
-
proxy_redirect ~^http://([a-zA-Z0-9\-]+\.)*chatgpt\.com(?<path>.*)$ https://$host${path};
|
46 |
|
47 |
-
|
48 |
-
proxy_cookie_domain chatgpt.com $host;
|
49 |
-
# 可能需要更具体的子域名处理,例如:
|
50 |
-
# proxy_cookie_domain .chatgpt.com $host; (注意前面的点)
|
51 |
-
# proxy_cookie_domain auth0.openai.com $host; (如果登录通过 auth0.openai.com)
|
52 |
|
53 |
-
#
|
54 |
-
#
|
55 |
-
#
|
56 |
-
#
|
57 |
-
#
|
58 |
-
# proxy_set_header Upgrade $http_upgrade;
|
59 |
-
# proxy_set_header Connection "upgrade";
|
60 |
-
# proxy_set_header Host chatgpt.com;
|
61 |
-
# proxy_set_header X-Real-IP $remote_addr;
|
62 |
-
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
63 |
-
# proxy_set_header X-Forwarded-Proto $scheme;
|
64 |
# }
|
65 |
}
|
66 |
}
|
|
|
9 |
scgi_temp_path /tmp/scgi_temp 1 2;
|
10 |
|
11 |
access_log /dev/stdout;
|
12 |
+
error_log /dev/stderr info;
|
13 |
|
14 |
location / {
|
15 |
+
proxy_pass https://demo.fuclaude.com;
|
|
|
16 |
|
17 |
+
# --- 关键: 伪装请求头,使其更像浏览器 ---
|
18 |
+
proxy_set_header Host demo.fuclaude.com;
|
|
|
|
|
19 |
proxy_set_header X-Real-IP $remote_addr;
|
20 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
21 |
proxy_set_header X-Forwarded-Proto $scheme;
|
22 |
+
|
23 |
+
# 1. 设置一个常见的浏览器 User-Agent
|
24 |
proxy_set_header User-Agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36";
|
25 |
+
|
26 |
+
# 2. 设置常见的 Accept 头
|
27 |
proxy_set_header Accept "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9";
|
28 |
+
proxy_set_header Accept-Language "en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7"; # 可以根据需要调整语言
|
29 |
+
|
30 |
+
# 3. 清除或设置 Accept-Encoding
|
31 |
+
# 有些 Cloudflare 设置可能不喜欢代理服务器声明它能处理的压缩格式
|
32 |
+
# 尝试清空它,让后端服务器决定是否压缩,或者让它发送未压缩的内容。
|
33 |
proxy_set_header Accept-Encoding "";
|
34 |
+
# 或者,如果你想尝试让Nginx处理压缩:
|
35 |
+
# proxy_set_header Accept-Encoding "gzip, deflate, br"; # 但这可能与后端冲突
|
36 |
+
|
37 |
+
# 4. 其他可能相关的头部
|
38 |
+
proxy_set_header Upgrade-Insecure-Requests "1"; # 告诉服务器客户端支持从http升级到https
|
39 |
+
proxy_set_header DNT "1"; # Do Not Track
|
40 |
+
# proxy_set_header Referer ""; # 之前已经有了,可以保留或根据情况设置
|
41 |
|
42 |
proxy_buffering off;
|
43 |
|
44 |
proxy_ssl_server_name on;
|
45 |
proxy_ssl_protocols TLSv1.2 TLSv1.3;
|
46 |
|
47 |
+
proxy_redirect ~^https://(www\.)?demo\.fuclaude\.com(?<path>.*)$ https://$host${path};
|
48 |
+
proxy_redirect ~^http://(www\.)?demo\.fuclaude\.com(?<path>.*)$ https://$host${path};
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
+
proxy_cookie_domain demo.fuclaude.com $host;
|
|
|
|
|
|
|
|
|
51 |
|
52 |
+
# 如果Cloudflare返回的是403 Forbidden或类似的错误,可以尝试拦截并显示自定义错误
|
53 |
+
# proxy_intercept_errors on;
|
54 |
+
# error_page 403 /cloudflare_blocked.html;
|
55 |
+
# location = /cloudflare_blocked.html {
|
56 |
+
# return 200 "This site is protected by Cloudflare and the proxy request was blocked.";
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
# }
|
58 |
}
|
59 |
}
|