跳至主要内容

利用aws最低配置搭建frp内网穿透

利用aws最低配置搭建frp内网穿透

由于最近忙着搬家的时候,一直在考虑如何让2个地区来实现稳定的内网穿透,可以把2边的带宽利用起来!突然想起很早之前和鸟总一起搭建过的frp内网穿透.于是就折腾了起来了.

这次我们利用别人写好的一键脚本吧,自己懒得去编辑frp.ini文件了!

1. 服务器端安装说明(ubuntu 18)

wget --no-check-certificate https://raw.githubusercontent.com/clangcn/onekey-install-shell/master/frps/install-frps.sh -O ./install-frps.sh
chmod 700 ./install-frps.sh
./install-frps.sh install

安装过程中会有提示一些的参数,我们设置好就可以了!

Please input frps bind_port [1-65535](Default Server Port: 5443):
#输入frp提供服务的端口,用于服务器端和客户端通信,按Enter键表示默认5443,否则手动输入新端口

Please input frps dashboard_port [1-65535](Default dashboard_port: 6443):
#输入frp的控制台服务端口,用于查看frp工作状态,按Enter键表示默认6443,否则手动输入新端口

Please input frps vhost_http_port [1-65535](Default vhost_http_port: 80):
#输入frp进行http穿透的http服务端口,按Enter键表示默认80,否则手动输入新端口,一般不建议默认80

Please input frps vhost_https_port [1-65535](Default vhost_https_port: 443):
#输入frp进行https穿透的https服务端口,按Enter键表示默认443,否则手动输入新端口

Please input privilege_token (Default: WEWLRgwRjIJVPx2kuqzkGnvuftPLQniq):
#输入frp服务器和客户端通信的密码,默认是随机生成的,按Enter键表示按默认来,否则手动输入。frpc客户端需要这个接头暗号

Please input frps max_pool_count [1-200](Default max_pool_count: 50):
#设置每个代理可以创建的连接池上限,默认50

Please select log_level #####
    1: info
    2: warn
    3: error
    4: debug
#####################################################
Enter your choice (1, 2, 3, 4 or exit. default [1]):
#设置日志等级,4个选项,默认是info

Please input frps log_max_days [1-30]
    (Default log_max_days: 3 day):
#设置日志保留天数,范围是1到30天,默认保留3天。

##### Please select log_file #####
    1: enable
    2: disable
#####################################################
    Enter your choice (1, 2 or exit. default [1]):
#设置是否开启日志记录,默认开启,开启后日志等级及保留天数生效,否则等级和保留天数无效

安装完成以后会有总体的提示

Congratulations, frps install completed!
==============================================
You Server IP   : *.*.*.*  #你的服务器IP,各不相同
Bind port       : 5443
Dashboard port  : 6443
vhost http port : 80
vhost https port: 443
Privilege token : WEWLRgwRjIJVPx2kuqzkGnvuftPLQniq
Max Pool count  : 50
Log level       : info
Log max days    : 3
Log file        : enable
==============================================

常用命令包括:

./install-frps.sh update #版本更新
./install-frps.sh uninstall #卸载frps
frps start #服务启动
frps stop #服务停止
frps restart #重启服务
frps status #状态
frps config #参数设置
frps version #frps版本

至此,frp 服务端 frps 的安装已经成功,frps 会随服务器自动启动,无需手动设置。

小提示:记得检查 VPS 服务器是否开放以上涉及的端口,如未开放,请手动添加开放端口!

此时访问 http://你的服务器 IP:6443 可以查看 frp 各项状态,如下图所示。如果打不开此页面,很可能是服务器的 6443 端口没有开启。

2. 客户端安装

由于我们用的路由lede有frp功能的插件,那么我们就设置吧!Sandy喜欢自定义设置

把下面的参数修改成你自己的参数,然后放到自定义配置里面去,记得把注释去掉不然会出错!

[common]
server_addr = *.*.*.* #已安装好frp服务端frps的服务器Ip地址
server_port = 5443 #与之前frp服务端的设置保持一致,即Bind Port
token = ************** #与之前安装服务端时给出的token保持一致

[web1]
type = http
local_ip = 192.168.1.1 #表示要穿透的为路由器IP
local_port = 80
use_encryption = true
use_gzip = true
custom_domains = *.*.* #表示远程访问192.168.1.1需要的域名,可以为二级域名。如果没有域名建议提前申请,并指向服务器所在IP
http_user = *** #可选项,随便填写,表示访问域名时需要用这个用户名验证通过后,才能连接到内网,加了一道防护,更安全
http_pwd = ****** #可选项,随便填写,同上,用户名对应这个密码,输入正确才能连接到内网

[web2]
type = http
local_ip = 192.168.1.111 #按需填写,填写需要远程访问的第二个内网设备IP
local_port = 80
use_encryption = true
use_gzip = true
custom_domains = *.*.* #表示远程访问192.168.1.111需要的域名,需要与上文的域名有所区别
http_user = *** #可选项,用户名
http_pwd = ****** #可选项,用户密码

log_file = /dev/null
log_level = info
log_max_days = 3

然后我们可以看到服务器端里面的http已经连接

这样就大功告成了~

评论

此博客中的热门博文

阿里云通过Nginx中转Linode/digitalocean/AWS的V2ray协议,实现负载均衡

开篇文的废话.原因是Sandy做站服务器太多了,发现利用率不高,皮又痒了又想折腾了.v2ray是利器但是给人的感觉就是只能用一台服务器,官方也说不支持负载均衡,不会A服务器挂机,自动跳转到B服务器.这里就有点折磨人了.每个服务器挂了都要自己去改配置文件. 我们访问国外的服务器,如果没CN2的线路是非常慢的,起码不快!哈哈~现在VPS都便宜起码人手一个人有5台以上吧?这样的话我们就可以开整. 开整条件:国内VPS或者阿里云有CN2线路的机器最好是100MB-200MB的带宽的.保证你爽歪歪.但是Sandy在阿里云HK30MB下也测试了也可以达到30000KB以上,羡慕吧~我们可以开始了! 老规则工具先出: 没被gwf和谐的服务器1台(下文统称:主服务器) 国外服务器2台以上(下文统称:从服务器) nginx 1.9.5版本以上(推荐:lnmp1.4) v2ray croe 第一步: 在 主服务器 安装lnmp1.4,这里就不细说教程了.直接去 官方 看教程 安装完毕以后我们来升级Nginx让他支持stream模块 cd lnmp1.4 vi lnmp.conf 在Nginx_Modules_Options=‘’里面加入--with-stream Nginx_Modules_Options='--with-stream’ 然后执行升级命令 ./upgrade.sh nginx  第二步 修改nginx.conf文件 cd /usr/local/nginx/conf/nginx.conf 在 events { use epoll; worker_connections 51200; multi_accept on; } 下面加入 stream{ server{ listen 0.0.0.0:8080; proxy_pass v2ray_backend; proxy_timeout 10m; proxy_connect_timeout 5000ms; } upstream v2ray_backend{ server ...

利用haproxy来做V2RAY负载均衡

Sandy在之前有说过 阿里云通过Nginx中转Linode/digitalocean/AWS的V2ray协议,实现负载均衡 ,有些学童不想折腾nginx,那么我们可以用haproxy来折腾,不管是haproxy还是Nginx都可以在树莓派和局域网的PC机器折腾! 安装haproxy的教程就移步到-> haproxy安装教程 apt-get install haproxy 安装完毕,我们来修改haproxy的配置 vi /etc/haproxy/haproxy.cfg 里面内容全部删除,加入下面的内容 global ulimit-n 51200 log /dev/log local0 log /dev/log local1 notice chroot /var/lib/haproxy pidfile /var/run/haproxy.pid user haproxy group haproxy daemon defaults log global mode tcp retries 3 option dontlognull option redispatch #上游TCP服务器连接等待时间 timeout connect 5s timeout client 24h timeout server 24h #以下为Web管理页面设置,如不需要可以删除 listen admin_stats bind 0.0.0.0:8888 mode http log 127.0.0.1 local0 err stats refresh 30s stats uri /haproxy stats realm welcome login\ Haproxy stats auth admin:admin stats hide-version stat...

ssh over socks5:通过socks5 proxy来连接ssh服务器[转载]

最近因为不可描述的原因,我在aws soul的云主机访问不了,ssh、80、ss全部都被禁掉了。 80端口在chrome配置SwitchyOmega就可以了,但ssh不太好办,shell上配置http_proxy对ssh没什么用。 其实ssh自己就支持proxy。 注意这跟在ssh端口转发:远程和本地中介绍过使用ssh作为proxy的方法不同,ssh -D是为了用ssh做proxy,而不是通过proxy来连接ssh服务器。 TL;DR ssh -o ProxyCommand='nc -x 192.0.2.0:1080 %h %p' user@awshost 原理解析 $ man ssh_config ProxyCommand Specifies the command to use to connect to the server. The command string extends to the end of the line, and is executed using the user's shell ‘exec’ directive to avoid a lingering shell process. In the command string, any occurrence of ‘%h’ will be substituted by the host name to connect, ‘%p’ by the port, and ‘%r’ by the remote user name. The command can be basically anything, and should read from its standard input and write to its standard output. It should eventually connect an sshd(8) server running on some machine, or execute sshd -i somewhere. Host key management will be done using the HostName of the host being connected (defa...