[GH-ISSUE #2974] nginx 做代理 转发tcp 上传超过7m的文件报502 #2375

Closed
opened 2026-05-05 13:31:40 -06:00 by gitea-mirror · 9 comments
Owner

Originally created by @iCloudys on GitHub (Jun 9, 2022).
Original GitHub issue: https://github.com/fatedier/frp/issues/2974

Bug Description

正常按照教程搭建好客户端和服务端,如果直接使用服务端ip:端口号上传文件没问题,如果在服务端安装了nginx并且配置了proxy_pass 到本机的端口号,则上传超过7m会报502,并且log_level=trace没有日志信息

frpc Version

0.43.0

frps Version

0.43.0

System Architecture

linux/amd64

Configurations

frps.ini

[common]
bind_port = 223
log_level=trace

frpc.ini

[common]
server_addr = XXX.XXX.XXX.XXX
server_port = 223
log_level=trace

[tcp3]
type = tcp
remote_port=9877
local_ip = 127.0.0.1
local_port = 80

nginx.conf

server {
        listen       80;
        server_name  _;

        location /api/ {
	    client_max_body_size 1000M;
	    proxy_pass http://127.0.0.1:9877/;
	    proxy_redirect     off;  
            proxy_set_header   Host             $host;  
            proxy_set_header   X-Real-IP        $remote_addr;  
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;  
	}
    }
 

以上配置如果直接使用XXX.XXX.XXX.XXX:9877 上传文件没问题,如果使用XXX.XXX.XXX.XXX:80 文件超过7m就报502。
这边查看nginx日志和程序日志,以及frp日志,没有任何输出

Logs

No response

Steps to reproduce

...

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @iCloudys on GitHub (Jun 9, 2022). Original GitHub issue: https://github.com/fatedier/frp/issues/2974 ### Bug Description 正常按照教程搭建好客户端和服务端,如果直接使用服务端ip:端口号上传文件没问题,如果在服务端安装了nginx并且配置了proxy_pass 到本机的端口号,则上传超过7m会报502,并且log_level=trace没有日志信息 ### frpc Version 0.43.0 ### frps Version 0.43.0 ### System Architecture linux/amd64 ### Configurations frps.ini ``` [common] bind_port = 223 log_level=trace ``` frpc.ini ``` [common] server_addr = XXX.XXX.XXX.XXX server_port = 223 log_level=trace [tcp3] type = tcp remote_port=9877 local_ip = 127.0.0.1 local_port = 80 ``` nginx.conf ``` server { listen 80; server_name _; location /api/ { client_max_body_size 1000M; proxy_pass http://127.0.0.1:9877/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } ``` 以上配置如果直接使用XXX.XXX.XXX.XXX:9877 上传文件没问题,如果使用XXX.XXX.XXX.XXX:80 文件超过7m就报502。 这边查看nginx日志和程序日志,以及frp日志,没有任何输出 ### Logs _No response_ ### Steps to reproduce 1. 2. 3. ... ### Affected area - [ ] Docs - [ ] Installation - [ ] Performance and Scalability - [ ] Security - [ ] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [ ] Client Plugin - [ ] Server Plugin - [ ] Extensions - [ ] Others
gitea-mirror 2026-05-05 13:31:40 -06:00
Author
Owner

@Becods commented on GitHub (Jun 29, 2022):

依你的配置来看,frp转发tcp,由此可明确502发生在你的nginx上,请检查你的配置

<!-- gh-comment-id:1169514521 --> @Becods commented on GitHub (Jun 29, 2022): 依你的配置来看,frp转发tcp,由此可明确502发生在你的nginx上,请检查你的配置
Author
Owner

@supply9243 commented on GitHub (Jul 10, 2022):

添加这个试试
proxy_buffering off;

<!-- gh-comment-id:1179717955 --> @supply9243 commented on GitHub (Jul 10, 2022): 添加这个试试 proxy_buffering off;
Author
Owner

@iCloudys commented on GitHub (Jul 12, 2022):

@K2M74 依然不行

<!-- gh-comment-id:1181407977 --> @iCloudys commented on GitHub (Jul 12, 2022): @K2M74 依然不行
Author
Owner

@star7th commented on GitHub (Jul 25, 2022):

顺手看到了就回复下吧。我觉得,这样大概能解决: nginx配置里, client_max_body_size 1000M 放到location /api/ 块的外面而不是里面。然后重启nginx

<!-- gh-comment-id:1193672509 --> @star7th commented on GitHub (Jul 25, 2022): 顺手看到了就回复下吧。我觉得,这样大概能解决: nginx配置里, client_max_body_size 1000M 放到location /api/ 块的外面而不是里面。然后重启nginx
Author
Owner

@iCloudys commented on GitHub (Jul 28, 2022):

@star7th 这个方式试了,不行

<!-- gh-comment-id:1197621770 --> @iCloudys commented on GitHub (Jul 28, 2022): @star7th 这个方式试了,不行
Author
Owner

@github-actions[bot] commented on GitHub (Aug 28, 2022):

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

<!-- gh-comment-id:1229346865 --> @github-actions[bot] commented on GitHub (Aug 28, 2022): Issues go stale after 30d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.
Author
Owner

@iCloudys commented on GitHub (Sep 27, 2022):

@cainb 没解决,放弃转发的方案了

<!-- gh-comment-id:1258854274 --> @iCloudys commented on GitHub (Sep 27, 2022): @cainb 没解决,放弃转发的方案了
Author
Owner

@iCloudys commented on GitHub (Sep 28, 2022):

项目放公网了,所以不需要内网穿透了

在 2022-09-27 10:21:43,"cainb" @.***> 写道:

@cainb 没解决,放弃转发的方案了

这样子吖,那新方案方便分享下嘛(


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: @.***>

<!-- gh-comment-id:1260274313 --> @iCloudys commented on GitHub (Sep 28, 2022): 项目放公网了,所以不需要内网穿透了 在 2022-09-27 10:21:43,"cainb" ***@***.***> 写道: @cainb 没解决,放弃转发的方案了 这样子吖,那新方案方便分享下嘛( — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: ***@***.***>
Author
Owner

@iCloudys commented on GitHub (Oct 9, 2022):

项目放公网了,所以不需要内网穿透了

我最近换了 openvpn 方案,实测完全没问题,如果你的服务不需要对公众用户开放,只是私人范围使用,推荐可以试试 openvpn(

谢谢

<!-- gh-comment-id:1272478372 --> @iCloudys commented on GitHub (Oct 9, 2022): > > 项目放公网了,所以不需要内网穿透了 > > 我最近换了 openvpn 方案,实测完全没问题,如果你的服务不需要对公众用户开放,只是私人范围使用,推荐可以试试 openvpn( 谢谢
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#2375
No description provided.