Rename nginx.conf.template to nginx.conf
Browse files- nginx.conf.template → nginx.conf +29 -15
nginx.conf.template → nginx.conf
RENAMED
|
@@ -1,5 +1,3 @@
|
|
| 1 |
-
# nginx.conf.template
|
| 2 |
-
|
| 3 |
server {
|
| 4 |
listen 7860;
|
| 5 |
server_name _;
|
|
@@ -14,32 +12,48 @@ server {
|
|
| 14 |
error_log /dev/stderr info;
|
| 15 |
|
| 16 |
location / {
|
| 17 |
-
|
| 18 |
-
# envsubst 会替换这个占位符
|
| 19 |
-
proxy_pass ${TARGET_URL};
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
proxy_set_header Host
|
| 23 |
proxy_set_header X-Real-IP $remote_addr;
|
| 24 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 25 |
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
|
|
|
| 26 |
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";
|
|
|
|
|
|
|
| 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 |
proxy_set_header Accept-Encoding "";
|
| 30 |
-
|
| 31 |
-
proxy_set_header
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
proxy_buffering off;
|
| 34 |
|
| 35 |
proxy_ssl_server_name on;
|
| 36 |
proxy_ssl_protocols TLSv1.2 TLSv1.3;
|
| 37 |
|
| 38 |
-
|
| 39 |
-
proxy_redirect ~^
|
| 40 |
-
|
|
|
|
| 41 |
|
| 42 |
-
#
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
}
|
| 45 |
}
|
|
|
|
|
|
|
|
|
|
| 1 |
server {
|
| 2 |
listen 7860;
|
| 3 |
server_name _;
|
|
|
|
| 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 |
}
|