[GH-ISSUE #2596] [Feature Request] 客户端没有连接时,访问能否报503错误,而非404 #2068

Closed
opened 2026-05-05 13:19:55 -06:00 by gitea-mirror · 3 comments
Owner

Originally created by @m2276699 on GitHub (Sep 30, 2021).
Original GitHub issue: https://github.com/fatedier/frp/issues/2596

Describe the feature request

需求:做http转发时,nginx识别500错误时,需转发到其他可用服务
现状:当客户端没有连接时,frp返回的状态码是404,nginx无法转到备用服务器。
虽然可以识别404后转发到备用服务器,但是很多情况下都不现实,毕竟外网http服务经常被扫描,404多了就直接到备用服务器了。

Describe alternatives you've considered

当客户端没有连接时,frp返回的状态码是503

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @m2276699 on GitHub (Sep 30, 2021). Original GitHub issue: https://github.com/fatedier/frp/issues/2596 ### Describe the feature request 需求:做http转发时,nginx识别500错误时,需转发到其他可用服务 现状:当客户端没有连接时,frp返回的状态码是404,nginx无法转到备用服务器。 虽然可以识别404后转发到备用服务器,但是很多情况下都不现实,毕竟外网http服务经常被扫描,404多了就直接到备用服务器了。 ### Describe alternatives you've considered 当客户端没有连接时,frp返回的状态码是503 ### Affected area - [ ] Docs - [ ] Installation - [ ] Performance and Scalability - [ ] Security - [ ] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [ ] Client Plugin - [ ] Server Plugin - [ ] Extensions - [X] Others
Author
Owner

@blizard863 commented on GitHub (Oct 8, 2021):

提供下配置。

<!-- gh-comment-id:938584770 --> @blizard863 commented on GitHub (Oct 8, 2021): 提供下配置。
Author
Owner

@m2276699 commented on GitHub (Oct 10, 2021):

nginx

server {
    listen       80;
    server_name  x.abc.com;

    location / {
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header  Host $http_host;
        proxy_redirect off;
        proxy_read_timeout 300;
        proxy_pass http://127.0.0.1:2080/;
    }
}

frps.ini

[common]
bind_addr = 0.0.0.0
bind_port = 7879
bind_udp_port = 7880
kcp_bind_port = 7879
vhost_http_port = 2080
vhost_https_port = 20443
log_file = ./frps.log
log_level = info
log_max_days = 3
token = xxxxxx
max_pool_count = 50
authentication_timeout = 300
tcp_mux = true
custom_404_page = /mnt/frp/404.html

此时frpc没有启动。当访问x.abc.com时,frps返回的状态码是404,希望是503

<!-- gh-comment-id:939440856 --> @m2276699 commented on GitHub (Oct 10, 2021): nginx ``` server { listen 80; server_name x.abc.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_read_timeout 300; proxy_pass http://127.0.0.1:2080/; } } ``` frps.ini ``` [common] bind_addr = 0.0.0.0 bind_port = 7879 bind_udp_port = 7880 kcp_bind_port = 7879 vhost_http_port = 2080 vhost_https_port = 20443 log_file = ./frps.log log_level = info log_max_days = 3 token = xxxxxx max_pool_count = 50 authentication_timeout = 300 tcp_mux = true custom_404_page = /mnt/frp/404.html ``` 此时frpc没有启动。当访问x.abc.com时,frps返回的状态码是404,希望是503
Author
Owner

@fatedier commented on GitHub (Oct 11, 2021):

目前不太可能改成返回 503,含义和目前不是很匹配,frp 的服务端并不知道后端的服务是不可用还是不存在。

建议看是否能有其他的方式才判断是否重试。

<!-- gh-comment-id:939649673 --> @fatedier commented on GitHub (Oct 11, 2021): 目前不太可能改成返回 503,含义和目前不是很匹配,frp 的服务端并不知道后端的服务是不可用还是不存在。 建议看是否能有其他的方式才判断是否重试。
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#2068
No description provided.