地址:https://github.com/fatedier/frp
简介:一个高效的反向代理:A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.
最全面的官方教程文档:https://gofrp.org
Linux服务器启动 frps
命令:nohup ./frps -c frps.ini(无挂起启动命令。可以自定义个shell脚本,避免每次切换目录,再启动)
配置:frps.init
[common]
bind_port = 7000
token = 123456
Windows启动 frpc
CMD命令:frpc -c testzyh.ini
配置:testzyh.ini
C:\Users\Administrator\Desktop\frpjk>frpc -c testzyh.ini
2022/01/25 14:18:15 [W] [service.go:86] login to server failed: dial tcp 124.223.72.221:7000: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
dial tcp 124.223.72.221:7000: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.失败案例:腾讯云的Linux的frps启动成功,Windows的客户端启动失败。连接超时,无响应等。应为腾讯云服务器的,防火墙规则,对于进入服务器的是有限制。需要开启。(腾讯云服务器的服务器防火墙入站及出站规则限制)(路径:腾讯云网页控制台—》轻量服务器—》服务器—》防火墙—》添加规则)
自身问题:不知道Linux服务器的防火墙规则,导致不知道怎么做。
wireshark抓包(过滤规则:ip.addr == 124.223.72.221) 130 8.568352 192.168.1.155 124.223.72.221 TCP 66 63289 → 7000 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 WS=256 SACK_PERM=1 131 8.599347 124.223.72.221 192.168.1.155 ICMP 94 Destination unreachable (Host administratively prohibited) 142 9.571653 192.168.1.155 124.223.72.221 TCP 66 [TCP Retransmission] [TCP Port numbers reused] 63289 → 7000 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 WS=256 SACK_PERM=1 143 9.590816 124.223.72.221 192.168.1.155 ICMP 94 Destination unreachable (Host administratively prohibited) 219 11.584799 192.168.1.155 124.223.72.221 TCP 66 [TCP Retransmission] [TCP Port numbers reused] 63289 → 7000 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 WS=256 SACK_PERM=1 220 11.614667 124.223.72.221 192.168.1.155 ICMP 94 Destination unreachable (Host administratively prohibited)二.通过防火墙,开启端口
1.安装防火墙
安装iptables-services :
2.防火墙基本操作
查看版本: firewall-cmd --version
显示状态: firewall-cmd --state
查看所有打开的端口: netstat -anp开启防火墙 systemctl start firewalld
关闭防火墙 systemctl stop firewalld开启防火墙 service firewalld start
若遇到无法开启
先用:systemctl unmask firewalld.service
然后:systemctl start firewalld.service3.端口查询
查询指定端口是否已开 firewall-cmd --query-port=666/tcp
提示yes or no
查询所有开启的端口 netstat -anp
4.开启端口
如果上面端口查询没有开启的话,需要重新开启一下
开启端口命令
添加 firewall-cmd --zone=public --add-port=80/tcp --permanent (–permanent永久生效,没有此参数重启后失效)
重新载入 firewall-cmd --reload
查看 firewall-cmd --zone= public --query-port=80/tcp
删除 firewall-cmd --zone= public --remove-port=80/tcp --permanent
最终结果:终于结束痛苦的失败
Linux服务器启动:
[lighthouse@VM-16-13-centos ~]$ ./frp a 2022/01/25 15:15:40 [I] [root.go:200] frps uses config file: frps.ini 2022/01/25 15:15:40 [I] [service.go:192] frps tcp listen on 0.0.0.0:7000 2022/01/25 15:15:40 [I] [root.go:209] frps started successfullywindow客户端启动成功:
C:\Users\Administrator\Desktop\frpjk>frpc -c testzyh.ini 2022/01/25 15:15:49 [I] [service.go:234] login to server success, get run id [fc18ba4b6640781d], server udp port [0] 2022/01/25 15:15:49 [I] [proxy_manager.go:144] [fc18ba4b6640781d] proxy added: [test_web_1 test_web_2] 2022/01/25 15:15:49 [I] [control.go:153] [test_web_1] start proxy success 2022/01/25 15:15:49 [I] [control.go:153] [test_web_2] start proxy successLinux服务器响应成功:
[lighthouse@VM-16-13-centos ~]$ ./frp a 2022/01/25 15:15:40 [I] [root.go:200] frps uses config file: frps.ini 2022/01/25 15:15:40 [I] [service.go:192] frps tcp listen on 0.0.0.0:7000 2022/01/25 15:15:40 [I] [root.go:209] frps started successfully 2022/01/25 15:15:48 [I] [service.go:447] [fc18ba4b6640781d] client login info: ip [115.219.252.237:59640] version [0.29.0] hostname [] os [windows] arch [amd64] 2022/01/25 15:15:48 [I] [tcp.go:63] [fc18ba4b6640781d] [test_web_1] tcp proxy listen port [15556] 2022/01/25 15:15:48 [I] [control.go:444] [fc18ba4b6640781d] new proxy [test_web_1] success 2022/01/25 15:15:48 [I] [tcp.go:63] [fc18ba4b6640781d] [test_web_2] tcp proxy listen port [15557] 2022/01/25 15:15:48 [I] [control.go:444] [fc18ba4b6640781d] new proxy [test_web_2] success其他的验证方法,使用telnet进行验证:
- 前置步骤,安装:
sudo yum install telnet#成功连接 [lighthouse@VM-16-13-centos ~]$ telnet 124.223.72.221 7000 Trying 124.223.72.221... Connected to 124.223.72.221. Escape character is '^]'. Connection closed by foreign host. #失败连接 [lighthouse@VM-16-13-centos ~]$ telnet 124.223.72.221 7000 Trying 124.223.72.221... telnet: connect to address 124.223.72.221: No route to host要检查一下这几个方面:
- 服务器端口是否可用,客户端是去连接服务器的相应端口的,所以要保证端口是能被客户端访问的
(1)先看看服务器是否开启了任务监听对应端口,我这里端口是7000
sudo netstat -tunlp | grep 7000(2)如果任务已开始监听,然后看看防火墙是否开放了这个端口,很重要
sudo iptables -L -n --line-numbers | grep 7000(3)如果防火墙没有开启这个端口,需要自己添加规则开启
sudo iptables -I INPUT -ptcp --dport 7000 -j ACCEPT(4)补充iptables相关命令
查找所有规则
sudo iptables -L INPUT --line-numbers
[common]
token = 123456
# Linux服务器的公网IP地址
server_addr = 124.223.72.221
server_port = 7000
[test_web_1]
type = tcp
local_ip = 127.0.0.1
local_port = 8080
remote_port = 15556
[test_web_2]
type = tcp
local_ip = 127.0.0.1
local_port = 8180
remote_port = 15557
略
我已经构建了一些serverspec代码来在多个主机上运行一组测试。问题是当任何测试失败时,测试会在当前主机停止。即使测试失败,我也希望它继续在所有主机上运行。Rakefile:namespace:specdotask:all=>hosts.map{|h|'spec:'+h.split('.')[0]}hosts.eachdo|host|begindesc"Runserverspecto#{host}"RSpec::Core::RakeTask.new(host)do|t|ENV['TARGET_HOST']=hostt.pattern="spec/cfengine3/*_spec.r
我正在尝试在Rails上安装ruby,到目前为止一切都已安装,但是当我尝试使用rakedb:create创建数据库时,我收到一个奇怪的错误:dyld:lazysymbolbindingfailed:Symbolnotfound:_mysql_get_client_infoReferencedfrom:/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundleExpectedin:flatnamespacedyld:Symbolnotfound:_mysql_get_client_infoReferencedf
我需要一个非常简单的字符串验证器来显示第一个符号与所需格式不对应的位置。我想使用正则表达式,但在这种情况下,我必须找到与表达式相对应的字符串停止的位置,但我找不到可以做到这一点的方法。(这一定是一种相当简单的方法……也许没有?)例如,如果我有正则表达式:/^Q+E+R+$/带字符串:"QQQQEEE2ER"期望的结果应该是7 最佳答案 一个想法:你可以做的是标记你的模式并用可选的嵌套捕获组编写它:^(Q+(E+(R+($)?)?)?)?然后你只需要计算你获得的捕获组的数量就可以知道正则表达式引擎在模式中停止的位置,你可以确定匹配结束
我正在尝试在配备ARMv7处理器的SynologyDS215j上安装ruby2.2.4或2.3.0。我用了optware-ng安装gcc、make、openssl、openssl-dev和zlib。我根据README中的说明安装了rbenv(版本1.0.0-19-g29b4da7)和ruby-build插件。.这些是随optware-ng安装的软件包及其版本binutils-2.25.1-1gcc-5.3.0-6gconv-modules-2.21-3glibc-opt-2.21-4libc-dev-2.21-1libgmp-6.0.0a-1libmpc-1.0.2-1libm
一段时间以来,我一直在使用open_uri下拉ftp路径作为数据源,但突然发现我几乎连续不断地收到“530抱歉,允许的最大客户端数(95)已经连接。”我不确定我的代码是否有问题,或者是否是其他人在访问服务器,不幸的是,我无法真正确定谁有问题。本质上,我正在读取FTPURI:defself.read_uri(uri)beginuri=open(uri).readuri=="Error"?nil:urirescueOpenURI::HTTPErrornilendend我猜我需要在这里添加一些额外的错误处理代码...我想确保我采取一切预防措施来关闭所有连接,这样我的连接就不是问题所在,但是我
我在思考流量控制的最佳实践。我应该走哪条路?1)不要检查任何东西并让程序失败(更清晰的代码,自然的错误消息):defself.fetch(feed_id)feed=Feed.find(feed_id)feed.fetchend2)通过返回nil静默失败(但是,“CleanCode”说,你永远不应该返回null):defself.fetch(feed_id)returnunlessfeed_idfeed=Feed.find(feed_id)returnunlessfeedfeed.fetchend3)抛出异常(因为不按id查找feed是异常的):defself.fetch(feed_id
我正在为毕业设计开发GEM,TravisCI构建不断失败。这是我在Travis上的链接:https://travis-ci.org/ricardobond/perpetuus/builds/8709218构建错误是:$bundleexecrakerakeaborted!Don'tknowhowtobuildtask'default'/home/travis/.rvm/gems/ruby-1.9.3-p448/bin/ruby_noexec_wrapper:14:in`eval'/home/travis/.rvm/gems/ruby-1.9.3-p448/bin/ruby_noexec_
运行:ruby1.9.3p0和Rails3.2.1尝试使用rspec但当我尝试将其安装到我的应用程序中时出现以下错误:/Users/Si/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.1/lib/rails/railtie/configuration.rb:85:in`method_missing':undefinedmethod`generators'for#(NoMethodError)from/Users/Si/.rvm/gems/ruby-1.9.3-p0/gems/rspec-rails-2.0.0.beta.18/lib/rspec-r
我正在运行这样的代码:ifvalid_from>Date.today当我运行它时,我得到一个错误提示comparisonofDatewithnilfailed我假设它正在发生,因为在某些情况下valid_from是nil。有没有办法避免出现此错误? 最佳答案 你可以这样做:ifvalid_fromandvalid_from>Date.today...end这将在第一个子句上短路,因为valid_from为nil,因此为false。 关于ruby-Date与nil的比较失败-ruby,我们
基本上我想要做的是在MyModelLog表中记录对MyModel的操作。这是一些伪代码:classMyModel我也有一个看起来像这样的模型:classMyModelLog"somethinghappened")endend为了记录我尝试:在MyModel的something方法中添加MyModelLog.log_something在MyModel的after_validation回调上调用MyModelLog.log_something在这两种情况下,创建都会在验证失败时回滚,因为它在验证事务中。当然我也想在验证失败时记录。我真的不想登录文件或数据库以外的其他地方,因为我需要日志条目