mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 08:05:49 -06:00
[GH-ISSUE #3912] 请教一下使用Nginx作为frps前置反向代理的配置 #3100
Labels
No labels
In Progress
WIP
WaitingForInfo
bug
doc
duplicate
easy
enhancement
future
help wanted
invalid
lifecycle/stale
need-issue-template
need-usage-help
no plan
proposal
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/frp#3100
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Fiary-Tale on GitHub (Jan 5, 2024).
Original GitHub issue: https://github.com/fatedier/frp/issues/3912
Bug Description
Bug Description

当我配置完代理后,我去访问我配置的58880端口时,会发现跳转到frp错误页面
frps日志错误为:2024/01/06 06:39:08 [W] [http.go:119] do http proxy request [host: localhost:58880] error: no route found: localhost /
我记得老的版本可以这样访问,因为我要做nginx反向代理,同时要将通过IP访问进行禁用,只允许通过域名进行访问。
frpc Version
0.53.2
frps Version
0.53.2
System Architecture
linux/adm64
Configurations
我的frps.toml配置是


我的frpc.toml配置是
Logs
2024/01/06 06:09:34 [W] [http.go:119] do http proxy request [host: 127.0.0.1:58880] error: no route found: 127.0.0.1 /
2024/01/06 06:09:50 [W] [http.go:119] do http proxy request [host: 10.0.8.10:58880] error: no route found: 10.0.8.10 /
2024/01/06 06:09:53 [W] [http.go:119] do http proxy request [host: 10.0.8.10:58880] error: no route found: 10.0.8.10 /
2024/01/06 06:10:01 [W] [http.go:119] do http proxy request [host: localhost:58880] error: no route found: localhost /
2024/01/06 06:39:08 [W] [http.go:119] do http proxy request [host: localhost:58880] error: no route found: localhost /
Steps to reproduce
...
Affected area
@superzjg commented on GitHub (Jan 6, 2024):
先弄清楚
localAddr与localIP的使用场景@Fiary-Tale commented on GitHub (Jan 6, 2024):
首先,非常感谢您的回复,为我解答疑惑,其次抱歉,我在文档中,并没有找到

localAddr的使用案例,也没有找到讲解方法,但是我不使用localAddr或localIP时,在客户端设置remotePort = 58880,服务端设置vhostHTTPPort = 58880时,我使用curl http://127.0.0.1:58880,一样会产生错误,导致我无法使用nginx反向代理设置。错误如下图访问http://127.0.0.1:58880
frps配置
`bindAddr = "0.0.0.0"
bindPort = 60001
vhostHTTPPort = 58880
log.to = "console"
auth.method = "token"
auth.token = "xxxxxxxxxxx"
`
frpc配置
`serverAddr = "1.1.1.1" # 这里我写的是真实ip,1.1.1.1只是临时填写
serverPort = 60001
auth.method = "token"
auth.token = "xxxxxxxxxxx"
proxies
name = "lskyweb"
type = "http"
localIP = "127.0.0.1"
localPort = 8080
remotePort = 58880
customDomains = ["1.1.1.1"] # 这里我写的是真实ip,1.1.1.1只是临时填写
`
frps错误日志
[W] [http.go:119] do http proxy request [host: 127.0.0.1:58880] error: no route found: 127.0.0.1 /此时如果我的vps开放了58880端口,使用
curl http://x.x.x.x:58880这个时候是可以正常访问的,唯独访问localhost、127.0.0.1或内网ip的58880端口无法访问@Fiary-Tale commented on GitHub (Jan 6, 2024):
我看到,您在其他nginx反向代理的issue中提到要先添加
localIP,那么我添加localIP后,配置如下:`serverAddr = "1.1.1.1"
serverPort = 60001
auth.method = "token"
auth.token = "xxxxxxx"
proxies
name = "lskyweb"
type = "http"
localIP = "127.0.0.1"
localPort = 8080
remotePort = 58880
customDomains = ["1.1.1.1"]
`
但是依旧会无法访问localhost、127.0.0.1或内网ip的58880端口,但是可以通过公网ip进行访问,我在公网服务器的shell中

访问错误如下:
2024/01/06 22:09:16 [W] [http.go:119] do http proxy request [host: 127.0.0.1:58880] error: no route found: 127.0.0.1 /
@Fiary-Tale commented on GitHub (Jan 6, 2024):
已经搞明白如何进行反向代理的设置了,需要把customDomains = ["1.1.1.1"]这个配置为customDomains = ["127.0.0.1"],就会默认转发到他的127.0.0.1:58880端口上,这样就可以做nginx反向代理了
@Lioncky commented on GitHub (May 3, 2025):
我遇到的问题更诡异 ngix反代直接挂掉 我还以为frps出问题了 结果正常走127.0.0.1:RemotePort可以正常访问 重启了下服务器ok了 反代要设置Proxy_host 也就是 127.0.0.1 这个还没文档的差评
ngix 反代设置 不需要用frps的v1 v2 ngix直接可以拿到X-Real-IP