内网穿透打洞

来自linux中国网wiki
Evan讨论 | 贡献2020年12月12日 (六) 12:09的版本 →‎https
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳到导航 跳到搜索

frp

另外一个推荐

内网穿透工具——ZeroTier One

https://www.zerotier.com/

内网穿透工具——ZeroTier One的使用



info

54.153.89.195 dev.evanlinux.com 54.153.89.195 devshop.evanlinux.com

192.168.0.11

install

https://github.com/fatedier/frp/releases/download/v0.30.0/frp_0.30.0_linux_amd64.tar.gz

wget https://github.com/fatedier/frp/releases/download/v0.9.3/frp_0.9.3_linux_amd64.tar.gz
tar -zxvf frp_0.9.3_linux_amd64.tar.gz
cd frp_0.9.3_linux_amd64

run

 
#server
./frps  -c  frps.ini

#client
./frpc  -c frpc.ini

建议线上用 screen 
然后  ./frps -c ./frps.ini & 

or nohup 

for leanote 201911

#今天用的版本是0.30.0 on debian for leanote

#cat  /data/apps/frp/frps.ini 
#/usr/bin/nohup   /data/apps/frp/frps -c /data/apps/frp/frps.ini &
[common]
bind_port = 7000
vhost_http_port = 9000
#vhost_http_port = 88

[leanote]
type = http
auth_token = 123
custom_domains =t.linuxsa.org



# cat  /data/apps/frp/frpc.ini 
# /usr/bin/nohup  /data/apps/frp/frpc -c /data/apps/frp/frpc.ini &
[common]
server_addr = 138.197.220.125
server_port = 7000
auth_token = 123

[leanote]
type = http
local_port = 9000
custom_domains =t.linuxsa.org

#[ssh]
#type = tcp
#local_ip = 127.0.0.1
#local_port = 22
#remote_port = 6000




cat    systemd/frps.service 
[Unit]
Description=Frp Server Service
After=network.target

[Service]
Type=simple
User=nobody
Restart=on-failure
RestartSec=5s
ExecStart=/data/apps/frp/frps -c /data/apps/frp/frps.ini
#ExecStart=/usr/bin/frps -c /etc/frp/frps.ini

[Install]
WantedBy=multi-user.target


cp     systemd/frps.service   /usr/lib/systemd/system/frps.service
chmod +x /usr/lib/systemd/system/frps.service







#other

#cat frps.ini 
[common]
bind_port = 7000
vhost_http_port = 9000
#vhost_http_port = 88

[leanote]
type = http
auth_token = 123
custom_domains =t.linuxsa.org


#cat frpc.ini 
[common]
server_addr = 138.197.220.125
server_port = 7000
auth_token = 123

[leanote]
type = http
local_port = 9000
custom_domains =t.linuxsa.org


#[ssh]
#type = tcp
#local_ip = 127.0.0.1
#local_port = 22
#remote_port = 6000



#other test

#今天用的版本是0.21
# frps.ini
[common]
bind_port = 7000
vhost_http_port = 80
#subdomain_host = evanlinux.com 

[web]
type = http
custom_domains = t.linuxsa.org
auth_token = 123


# frpc.ini
[common]
server_addr = 45.77.26.200
server_port = 7000
auth_token = 123

[web]
type = http
local_port = 8080
custom_domains = t.linuxsa.org

打开   t.linuxsa.org
#这个跳转 应试是docker的问题 因为 8888的cmdb不会跳的 
最终跳到 http://192.168.0.10:8080/

frp开胃菜

 cat  frpc.ini
# frpc.ini
[common]
server_addr = 54.153.89.195
server_port = 7000
auth_token = 123

[web]
type = http
#local_port = 80
local_port = 8000


 cat frps.ini 
# frps.ini
[common]
bind_port = 7000
vhost_http_port = 80
#subdomain_host = evanlinux.com 

[web]
type = http
custom_domains = evanlinux.com
#custom_domains = *.evanlinux.com
auth_token = 123

visa   evanlinux.com 就是内网的8000tomcat应用

进阶

custom_domains多个域名

frps

# frps.ini
[common]
bind_port = 7000
vhost_http_port = 80
#subdomain_host = evanlinux.com 

[web]
type = http
custom_domains = evanlinux.com
#custom_domains = *.evanlinux.com
auth_token = 123

[web02]
vhost_http_port = 80
type = http
auth_token = 123
custom_domains = devshop.evanlinux.com


[web03]
vhost_http_port = 80
type = http
auth_token = 123
custom_domains = dev.evanlinux.com

#https
[web02s]
vhost_https_port = 443
type = https
auth_token = 123
custom_domains = devread.com

frpc

# frpc.ini
[common]
server_addr = 54.153.89.195
server_port = 7000
auth_token = 123

[web]
type = http
#local_port = 80
local_port = 8000
#subdomain = devshop

[web02]
type = http
local_port = 5080
custom_domains = devshop.evanlinux.com


[web03]
type = http
local_port = 7080
custom_domains = dev.evanlinux.com

#https
[web02s]
type = https
local_port = 443
custom_domains = devread.com

dns

devshop.evanlinux.com dev.evanlinux.com 记得A到 frps 机器上去


cus 80 eg

#request nginx has  dev.evanlinux.com   devshop.evanlinux.com
# frpc.ini
[common]
server_addr = 54.153.89.195
server_port = 7000
auth_token = 123

[web]
type = http
#local_port = 80
local_port = 8000
#subdomain = devshop

[web02]
type = http
#local_port = 5080
local_port = 80
custom_domains = devshop.evanlinux.com


[web03]
type = http
#local_port = 5080
local_port = 80
custom_domains = dev.evanlinux.com

使用 80 端口访问

些时候必须使用 80  端口访问网站服务,比如微信公众号服务。将服务器端的 vhost_http_port 参数配置成 80 就可以了。
但是,有时候 80 端口被 apache 或 nginx 使用了,那么就要通过修改 apache 或 nginx 的配置来解决。修改配置的目的是将域名域名对应的 80 端口转发到 vhost_http_port 配置的端口上来。

以 nginx 为例:

server {
    listen       80;
    server_name  frp.biliyu.com;

    #charset koi8-r;
    #access_log  logs/host.access.log  main;

    location / {
        proxy_set_header Host $host;
        proxy_set_header X_Real_IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_pass http://127.0.0.1:8080;
    }
}

说明

说明:

server_addr 公网IP
server_port 服务器端口
local_port 本地要替换的端口
remote_port 替换端口(ssh连接时候改成这个端口)
local_port 本地http服务的端口号
custom_domains 有公网IP服务器的域名(必须有域名,否则无法实现http)

不太好用

花生壳有 linux 版本,支持内网穿透,容器跑一个就行了。

https://hsk.oray.com/download/

see also

frp系列

https://www.cnblogs.com/sanduzxcvbnm/category/1171545.html

七、利用frp 穿透到内网的http/https网站,实现对外开放


树莓派3B+(06):frp内网穿透ssh

轻量级内网穿透代理服务器 NPS

https://github.com/cnlh/nps/

install config

frp官方中文文档

https://www.oschina.net/p/frp

linux、centos7 安装 frp 搭建高性能内网穿透服务

使用frp实现内网穿透

推荐一款很好用的内网穿透工具 FRP

n2n内网穿透神器(一条命令实现穿透)(linux,安卓,win,openwrt全介绍)

利用 frp 进行内网穿透

使用 frp 实现内网穿透

frp 内网穿透

n2n内网穿透打洞部署全过程 + nginx公网端口映射

十分钟教你配置frp实现内网穿透

使用frp实现内网穿透

内网穿透都有哪些解决方案

内网穿透工具frp使用说明

Linux 配置frp,实现内网穿透

frp内网穿透配置

搭建frp实现内网穿透

自建服务器解决外网访问内网(内网穿透【端口映射】)问题的方法总结

使用frp实现内网穿透

https

letsencrypt + frp + iris 实现https内网穿透

搭建 frp 内网穿透并启用 HTTPS 访问


内网穿透网络

搭建Zerotier内网穿透网络及彻底删除zerotier方法