[GH-ISSUE #2153] 火狐时不时的出现400 bad request 错误,谷歌不会。 #1716

Closed
opened 2026-05-05 13:06:03 -06:00 by gitea-mirror · 2 comments
Owner

Originally created by @ihappywall on GitHub (Dec 15, 2020).
Original GitHub issue: https://github.com/fatedier/frp/issues/2153

frps.ini
[common]
bind_port = 7000
token=xxxxxxxxxxxx
vhost_http_port = 8081
vhost_https_port = 8082
log_file = /home/frp/frps.log
log_level = trace
log_max_days = 7

dashboard_port=7500
dashboard_user=xxx
dashboard_pwd=xxx
frpc.ini
[common]
server_addr = xx.xx.xxx.xxx
server_port = 7000
token=xxxxxxxxxx

log_file = ./frps.log
log_level = info
log_max_days = 7

[test_htts2http]
type = https
custom_domains = xxxx.xxxxxxxxxx.com
plugin = https2http
plugin_local_addr = xxx.xxx.x.x:8080
plugin_crt_path = D:/xxx/xxx/xxxx/xxxxxx.com.pem
plugin_key_path = D:/xxx/xxx/xxxx/xxxxxx.com.key
plugin_host_header_rewrite = xxx.xxx.x.x
jquery脚本 发送post请求
      var $inputFile = $(e.currentTarget);
      var formData = new FormData();
      formData.append("picture", $inputFile[0].files[0]);

      $.ajax({
        url: url,
        type: 'post',
        dataType: 'json',
        data: formData,
        contentType: false,
        processData: false,
        success: function(json) {},
        error: function(xhr, ajaxOptions, thrownError) {
          console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
          alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
      });

我也是出现了400 bad request问题。
就是在火狐浏览器上用 post multiple/form-data方式上传10几k的图片,有时候可以,有时候就返回400错误。并且发现火狐浏览器重新刷新一下,特别容易出现post multiple/form-data 上传文件的400错误。
在谷歌浏览器就没有这个问题。
首先可以确定不是web后端程序问题,在出现400错误时,后端的访问日志看不到访问记录。应该也不是前端的问题。
然后看frps.log 和 frpc.log 都看不到什么相关的错误日志。
看了一下go程序:
在 /pkg/plugin/client/http_proxy.go文件

func (hp *HTTPProxy) handleConnectReq(req *http.Request, rwc io.ReadWriteCloser) {
	defer rwc.Close()
	if ok := hp.Auth(req); !ok {
		res := getBadResponse()
		res.Write(rwc)
		return
	}

	remote, err := net.Dial("tcp", req.URL.Host)
	if err != nil {
		res := &http.Response{
			StatusCode: 400,
			Proto:      "HTTP/1.1",
			ProtoMajor: 1,
			ProtoMinor: 1,
		}
		res.Write(rwc)
		return
	}
	rwc.Write([]byte("HTTP/1.1 200 OK\r\n\r\n"))

	frpIo.Join(remote, rwc)
}

这里有返回了400错误,却不打印任何日志。会不会是这个地方的错误,net.Dial的错误。

Originally created by @ihappywall on GitHub (Dec 15, 2020). Original GitHub issue: https://github.com/fatedier/frp/issues/2153 ``` frps.ini [common] bind_port = 7000 token=xxxxxxxxxxxx vhost_http_port = 8081 vhost_https_port = 8082 log_file = /home/frp/frps.log log_level = trace log_max_days = 7 dashboard_port=7500 dashboard_user=xxx dashboard_pwd=xxx ``` ``` frpc.ini [common] server_addr = xx.xx.xxx.xxx server_port = 7000 token=xxxxxxxxxx log_file = ./frps.log log_level = info log_max_days = 7 [test_htts2http] type = https custom_domains = xxxx.xxxxxxxxxx.com plugin = https2http plugin_local_addr = xxx.xxx.x.x:8080 plugin_crt_path = D:/xxx/xxx/xxxx/xxxxxx.com.pem plugin_key_path = D:/xxx/xxx/xxxx/xxxxxx.com.key plugin_host_header_rewrite = xxx.xxx.x.x ``` ``` jquery脚本 发送post请求 var $inputFile = $(e.currentTarget); var formData = new FormData(); formData.append("picture", $inputFile[0].files[0]); $.ajax({ url: url, type: 'post', dataType: 'json', data: formData, contentType: false, processData: false, success: function(json) {}, error: function(xhr, ajaxOptions, thrownError) { console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); ``` 我也是出现了400 bad request问题。 就是在火狐浏览器上用 post multiple/form-data方式上传10几k的图片,有时候可以,有时候就返回400错误。并且发现火狐浏览器重新刷新一下,特别容易出现post multiple/form-data 上传文件的400错误。 在谷歌浏览器就没有这个问题。 首先可以确定不是web后端程序问题,在出现400错误时,后端的访问日志看不到访问记录。应该也不是前端的问题。 然后看frps.log 和 frpc.log 都看不到什么相关的错误日志。 看了一下go程序: 在 /pkg/plugin/client/http_proxy.go文件 ``` func (hp *HTTPProxy) handleConnectReq(req *http.Request, rwc io.ReadWriteCloser) { defer rwc.Close() if ok := hp.Auth(req); !ok { res := getBadResponse() res.Write(rwc) return } remote, err := net.Dial("tcp", req.URL.Host) if err != nil { res := &http.Response{ StatusCode: 400, Proto: "HTTP/1.1", ProtoMajor: 1, ProtoMinor: 1, } res.Write(rwc) return } rwc.Write([]byte("HTTP/1.1 200 OK\r\n\r\n")) frpIo.Join(remote, rwc) } ``` 这里有返回了400错误,却不打印任何日志。会不会是这个地方的错误,net.Dial的错误。
gitea-mirror 2026-05-05 13:06:03 -06:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 30, 2021):

Issues go stale after 45d of inactivity. Stale issues rot after an additional 10d of inactivity and eventually close.

<!-- gh-comment-id:770131046 --> @github-actions[bot] commented on GitHub (Jan 30, 2021): Issues go stale after 45d of inactivity. Stale issues rot after an additional 10d of inactivity and eventually close.
Author
Owner

@luyanfeng commented on GitHub (Sep 3, 2024):

我也是, 我只是以http方式代理了下springboot服务 :

image
image

<!-- gh-comment-id:2325423474 --> @luyanfeng commented on GitHub (Sep 3, 2024): 我也是, 我只是以http方式代理了下springboot服务 : ![image](https://github.com/user-attachments/assets/2b1ff3ef-ee85-4f0a-abe5-6472c32a6692) ![image](https://github.com/user-attachments/assets/24bbc0d0-8630-43b7-9971-99d39991ba10)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#1716
No description provided.