mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 16:15:49 -06:00
[GH-ISSUE #53] 如何配合nginx使用? #18
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#18
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 @openmynet on GitHub (Jul 26, 2016).
Original GitHub issue: https://github.com/fatedier/frp/issues/53
远程服务器里有web服务,使用nginx作为服务前端,frp要如何配合nginx使用?
以下配置测试了行不通。需要如何配置
nginx配置:
server {
listen 80;
server_name demo.*;
location / {
proxy_pass http://127.0.0.1:7000;
}
}
frps.ini 配置
[common]
bind_port = 7000
vhost_http_port = 8008
[web01]
type = http
custom_domains = demo.exampledomain.com
frpc.ini 配置
[common]
server_addr = 162...*
[web01]
type = http
local_ip = 127.0.0.1
local_port = 80
@fatedier commented on GitHub (Jul 26, 2016):
我测试了一下这种情况是可以通过的,你可以检查下以下几个地方是否存在问题:
proxy_pass http://127.0.0.1:7000这个是 web 服务的地址吗?检查端口是否正确。可以直接访问 nginx 看是否有问题。@openmynet commented on GitHub (Jul 26, 2016):
1、配置文件中的auth_token 已配置成相同的了
2、为避免影响,暂时将nginx关掉了,frps.ini 中的 vhost_http_port = 80
3、服务端的frps从日志上看没有报错都是success
4、客户端的frpc 日志如下:
2016/07/26 15:21:28 [main.go:109] [I] Start frpc success 2016/07/26 15:21:29 [control.go:181] [I] Start to send heartbeat to frps 2016/07/26 15:21:48 [conn.go:182] [W] join connections error, read tcp 127.0.0.1:62754->127.0.0.1:80: read tcp 192.168.1.132:62755->162.*.*.201:7000: use of closed network connection 2016/07/26 15:21:51 [conn.go:182] [W] join connections error, read tcp 127.0.0.1:62758->127.0.0.1:80: read tcp 192.168.1.132:62759->162.*.*.201:7000: use of closed network connection@fatedier commented on GitHub (Jul 26, 2016):
你这个 frpc 好像用的不是最新的
0.7.0的版本,建议更新,有没有可能 frps 更新了 0.7.0 的版本,因为协议不兼容导致 frpc 无法正常工作。从日志来看像是连接刚建立就被中断了,如果不是上面的原因,可以将 frp 的代理类型 设置成 tcp 的方式测试一下是否正常,日志级别设置成 debug,方便定位问题。
@openmynet commented on GitHub (Jul 26, 2016):
frpc是winx64版本的0.7.0 ,包里面的frps.ini和linux64包里的frps.ini略有不同
@openmynet commented on GitHub (Jul 26, 2016):
以下是debug级别的通信信息:
2016/07/26 19:20:28 [main.go:109] [I] Start frpc success 2016/07/26 19:20:28 [control.go:160] [D] ProxyName [web01], read [{"type":3,"code":0,"msg":""} ] 2016/07/26 19:20:28 [control.go:173] [D] ProxyName [web01], connect to server [162.0.0.0:7000] success! 2016/07/26 19:20:28 [control.go:181] [I] Start to send heartbeat to frps 2016/07/26 19:20:48 [control.go:185] [D] Send heartbeat to server 2016/07/26 19:20:49 [control.go:101] [D] ProxyName [web01], receive heartbeat response 2016/07/26 19:21:06 [control.go:104] [D] ProxyName [web01], new user connection 2016/07/26 19:21:06 [client.go:91] [D] Join two connections, (l[127.0.0.1:65462] r[127.0.0.1:80]) (l[192.168.1.132:65463] r[162.0.0.0:7000]) 2016/07/26 19:21:06 [conn.go:182] [W] join connections error, read tcp 127.0.0.1:65462->127.0.0.1:80: read tcp 192.168.1.132:65463->162.0.0.0:7000: use of closed network connection 2016/07/26 19:21:07 [control.go:104] [D] ProxyName [web01], new user connection 2016/07/26 19:21:07 [client.go:91] [D] Join two connections, (l[127.0.0.1:65466] r[127.0.0.1:80]) (l[192.168.1.132:65467] r[162.0.0.0:7000]) 2016/07/26 19:21:07 [conn.go:182] [W] join connections error, read tcp 127.0.0.1:65466->127.0.0.1:80: read tcp 192.168.1.132:65467->162.0.0.0:7000: use of closed network connection 2016/07/26 19:21:08 [control.go:185] [D] Send heartbeat to server 2016/07/26 19:21:09 [control.go:101] [D] ProxyName [web01], receive heartbeat response 2016/07/26 19:21:28 [control.go:185] [D] Send heartbeat to server 2016/07/26 19:21:29 [control.go:101] [D] ProxyName [web01], receive heartbeat response 2016/07/26 19:21:48 [control.go:185] [D] Send heartbeat to server 2016/07/26 19:21:49 [control.go:101] [D] ProxyName [web01], receive heartbeat response@fatedier commented on GitHub (Jul 26, 2016):
从日志里面打印的代码行数来看,确实不是 0.7.0 版本的客户端,你用 ./frpc.exe --version 看一下版本号是否正确。而且我看 0.7.0 版本 windows 和 linux 压缩文件里的 frps.ini 是一样的。
@openmynet commented on GitHub (Jul 27, 2016):
问题找到了,frpc确实不是0.7.0的,包是使用远程服务器下载的,不知怎么的下到了0.6.0的
贴下运行nginx和frps成功后的配置
nginx:
frps.ini 配置 修改
frpc.ini 配置
其他的使用默认配置
@se77en commented on GitHub (Aug 26, 2016):
@openmynet 请教一下,我客户端也配置了一个 nginx,然后拿不到真实 IP,access-log 打出来都是 127.0.0.1,frp 配置方式是客户端特权模式
@openmynet commented on GitHub (Aug 30, 2016):
@se77en 客户端的nginx配置和网站服务器nginx配置类似
@yjiawqgj commented on GitHub (Aug 17, 2021):
请问你是用nginx来免端口访问内网的吗?我使用的是最新0.37.1版本,已经不适用你的配置了。能帮我看一下吗?如果可以请回复。