github 加速提示无效输入 #62

Closed
opened 2025-08-25 10:00:27 +08:00 by hausen1012 · 14 comments
hausen1012 commented 2025-08-25 10:00:27 +08:00 (Migrated from github.com)
这个链接不知道为什么提示无效输入。 https://github.com/TermoraDev/termora/releases/download/1.0.17/termora-1.0.17-windows-x86-64.zip
sky22333 commented 2025-08-25 10:51:49 +08:00 (Migrated from github.com)
没问题呀 https://demo.52013120.xyz/https://github.com/TermoraDev/termora/releases/download/1.0.17/termora-1.0.17-windows-x86-64.zip
hausen1012 commented 2025-08-25 11:02:51 +08:00 (Migrated from github.com)

不应该啊,我用的最新版镜像

不应该啊,我用的最新版镜像
hausen1012 commented 2025-08-25 11:15:06 +08:00 (Migrated from github.com)

换了个服务器可以下载,查看f12发现提示403,不知道是不是这台服务器被 github 拒绝了

换了个服务器可以下载,查看f12发现提示403,不知道是不是这台服务器被 github 拒绝了
sky22333 commented 2025-08-25 11:41:53 +08:00 (Migrated from github.com)

得看下日志才能知道

得看下日志才能知道
hausen1012 commented 2025-08-25 11:43:13 +08:00 (Migrated from github.com)

看docker日志没有异常

看docker日志没有异常
hausen1012 commented 2025-08-25 14:05:57 +08:00 (Migrated from github.com)
这个就不行:https://hubproxy.itxbbazt.eu.org/https://github.com/TermoraDev/termora/releases/download/1.0.17/termora-1.0.17-windows-x86-64.zip
hausen1012 commented 2025-08-25 14:06:44 +08:00 (Migrated from github.com)

日志

Image
日志 <img width="1359" height="352" alt="Image" src="https://github.com/user-attachments/assets/e8dd771a-b410-4454-8110-d015642e6120" />
sky22333 commented 2025-08-25 14:12:15 +08:00 (Migrated from github.com)

试试在服务端本地下载:

wget 127.0.0.1:5000/https://github.com/TermoraDev/termora/releases/download/1.0.17/termora-1.0.17-windows-x86-64.zip
试试在服务端本地下载: ``` wget 127.0.0.1:5000/https://github.com/TermoraDev/termora/releases/download/1.0.17/termora-1.0.17-windows-x86-64.zip ```
hausen1012 commented 2025-08-25 14:14:23 +08:00 (Migrated from github.com)

本地没问题 Image

本地没问题 <img width="1366" height="340" alt="Image" src="https://github.com/user-attachments/assets/23e36a62-5fe6-4f91-8a98-8ff56bfea5a4" />
hausen1012 commented 2025-08-25 17:09:06 +08:00 (Migrated from github.com)

修改了一下反代确实能下载,但是反代怎么能影响到这个斜杆的?

Image

只是这里有没有斜杆

Image
修改了一下反代确实能下载,但是反代怎么能影响到这个斜杆的? <img width="1363" height="231" alt="Image" src="https://github.com/user-attachments/assets/07276380-2b1d-47da-9d42-0e824c37db81" /> 只是这里有没有斜杆 <img width="614" height="138" alt="Image" src="https://github.com/user-attachments/assets/1ceee37b-882c-4056-a240-d44a7a4cb7ee" />
hausen1012 commented 2025-08-25 17:09:43 +08:00 (Migrated from github.com)

我看53的issue 也是

Image
我看53的issue 也是 <img width="1212" height="881" alt="Image" src="https://github.com/user-attachments/assets/9c5e45ac-7ad4-4402-bc37-b1a70947d368" />
hausen1012 commented 2025-08-25 17:29:51 +08:00 (Migrated from github.com)
	rawPath := strings.TrimPrefix(c.Request.URL.RequestURI(), "/")

	for strings.HasPrefix(rawPath, "/") {
		rawPath = strings.TrimPrefix(rawPath, "/")
	}

	// 自动补全协议头
	if !strings.HasPrefix(rawPath, "https://") {
		if strings.HasPrefix(rawPath, "http:/") || strings.HasPrefix(rawPath, "https:/") {
			rawPath = strings.Replace(rawPath, "http:/", "", 1)
			rawPath = strings.Replace(rawPath, "https:/", "", 1)
		} else if strings.HasPrefix(rawPath, "http://") {
			rawPath = strings.TrimPrefix(rawPath, "http://")
		}
		rawPath = "https://" + rawPath
	}

这一段的处理应该是有问题?

```sh rawPath := strings.TrimPrefix(c.Request.URL.RequestURI(), "/") for strings.HasPrefix(rawPath, "/") { rawPath = strings.TrimPrefix(rawPath, "/") } // 自动补全协议头 if !strings.HasPrefix(rawPath, "https://") { if strings.HasPrefix(rawPath, "http:/") || strings.HasPrefix(rawPath, "https:/") { rawPath = strings.Replace(rawPath, "http:/", "", 1) rawPath = strings.Replace(rawPath, "https:/", "", 1) } else if strings.HasPrefix(rawPath, "http://") { rawPath = strings.TrimPrefix(rawPath, "http://") } rawPath = "https://" + rawPath } ``` 这一段的处理应该是有问题?
sky22333 commented 2025-08-25 17:45:26 +08:00 (Migrated from github.com)

AI的解释

Nginx proxy_pass 尾部有 / 时,会触发 URI 重写和规范化,并且默认 merge_slashes on; 会把连续 // 合并成 /
如果请求路径包含 https://,就可能被折叠成 https:/,导致路径错误。

差异原因:

  • proxy_pass http://127.0.0.1:5000/;(有 /):Nginx 会替换 location 前缀并折叠 //https://https:/
  • proxy_pass http://127.0.0.1:5000;(无 /):原始 URI 不改写,https:// 保持不变。

nginx反代修复方案:

  1. 去掉尾部 /(最简单)
location / {
    proxy_pass http://127.0.0.1:5000;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
}

2:保留尾部 /,关闭斜杠折叠

location / {
    merge_slashes off;
    proxy_pass http://127.0.0.1:5000/;
}

3:原样转发请求 URI

location / {
    proxy_pass http://127.0.0.1:5000$request_uri;
}
### AI的解释 Nginx `proxy_pass` 尾部有 `/` 时,会触发 URI 重写和规范化,并且默认 `merge_slashes on;` 会把连续 `//` 合并成 `/`。 如果请求路径包含 `https://`,就可能被折叠成 `https:/`,导致路径错误。 差异原因: - `proxy_pass http://127.0.0.1:5000/;`(有 `/`):Nginx 会替换 location 前缀并折叠 `//`,`https://` → `https:/`。 - `proxy_pass http://127.0.0.1:5000;`(无 `/`):原始 URI 不改写,`https://` 保持不变。 nginx反代修复方案: 1. 去掉尾部 `/`(最简单) ``` location / { proxy_pass http://127.0.0.1:5000; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; } ``` 2:保留尾部 /,关闭斜杠折叠 ``` location / { merge_slashes off; proxy_pass http://127.0.0.1:5000/; } ``` 3:原样转发请求 URI ``` location / { proxy_pass http://127.0.0.1:5000$request_uri; } ```
hausen1012 commented 2025-08-25 17:51:41 +08:00 (Migrated from github.com)

ok,懂了,感谢。那请问既然后端默认会处理,那是不是可以在发起请求的时候就先把协议处理了?像这样:https://demo.52013120.xyz/github.com/TermoraDev/termora/releases/download/1.0.17/termora-1.0.17-windows-x86-64.zip

ok,懂了,感谢。那请问既然后端默认会处理,那是不是可以在发起请求的时候就先把协议处理了?像这样:https://demo.52013120.xyz/github.com/TermoraDev/termora/releases/download/1.0.17/termora-1.0.17-windows-x86-64.zip
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: 3344/hubproxy#62