[TOC]
相关文档
文档主页 - https://ehang-io.github.io/nps/#/install
NPS客户端配置实例 - https://github.com/ehang-io/nps/blob/master/conf/nps.conf
NPC客户端配置实例 - https://github.com/ehang-io/nps/blob/master/conf/npc.conf
Docker hub NPS - https://hub.docker.com/r/ffdfgdfg/nps
Docker hub NPC - https://hub.docker.com/r/ffdfgdfg/npc
docker下的NPS
nps的服务端
使用方式
docker pull ffdfgdfg/nps
下载conf文件夹并解压,或前往项目主页自行下载(升级请忽略)
继续阅读文档修改配置文件(升级请忽略)
启动:docker run -d --name nps --restart=always --net=host -v <本机conf目录>:/conf ffdfgdfg/nps
请确保为conf文件夹
查看日志docker logs nps
配置教程
下载文件(以0.26.10为例)
https://github.com/ehang-io/nps/releases/tag/v0.26.10
执行下列命令
mkdir /nps && cd /nps && yum -y install wget && wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_server.tar.gz && tar -zxvf linux_amd64_server.tar.gz
配置文件
vi conf/nps.conf
运行Docker
docker run -d --name nps --restart=always --net=host -v /nps/conf:/conf ffdfgdfg/nps
服务端配置文件 - nps.conf 详解
- /etc/nps/conf/nps.conf
名称 | 含义 |
---|---|
web_port | web管理端口 |
web_password | web界面管理密码 |
web_username | web界面管理账号 |
web_base_url | web管理主路径,用于将web管理置于代理子路径后面 |
bridge_port | 服务端客户端通信端口 |
https_proxy_port | 域名代理https代理监听端口 |
http_proxy_port | 域名代理http代理监听端口 |
auth_key | web api密钥 |
bridge_type | 客户端与服务端连接方式kcp或tcp |
public_vkey | 客户端以配置文件模式启动时的密钥,设置为空表示关闭客户端配置文件连接模式 |
ip_limit | 是否限制ip访问,true或false或忽略 |
flow_store_interval | 服务端流量数据持久化间隔,单位分钟,忽略表示不持久化 |
log_level | 日志输出级别 |
auth_crypt_key | 获取服务端authKey时的aes加密密钥,16位 |
p2p_ip | 服务端Ip,使用p2p模式必填 |
p2p_port | p2p模式开启的udp端口 |
pprof_ip | debug pprof 服务端ip |
pprof_port | debug pprof 端口 |
disconnect_timeout | 客户端连接超时,单位 5s,默认值 60,即 300s = 5mins |
流量数据持久化
服务端支持将流量数据持久化,默认情况下是关闭的,如果有需求可以设置nps.conf
中的flow_store_interval
参数,单位为分钟
注意: nps不会持久化通过公钥连接的客户端
系统信息显示
nps服务端支持在web上显示和统计服务器的相关信息,但默认一些统计图表是关闭的,如需开启请在nps.conf
中设置system_info_display=true
服务端多用户登陆
如果将nps.conf
中的allow_user_login
设置为true,服务端web将支持多用户登陆,登陆用户名为user,默认密码为每个客户端的验证密钥,登陆后可以进入客户端编辑修改web登陆的用户名和密码,默认该功能是关闭的。
用户注册功能
nps服务端支持用户注册功能,可将nps.conf
中的allow_user_register
设置为true,开启后登陆页将会有有注册功能,
docker下的NPC
nps的客户端npc
docker pull ffdfgdfg/npc
无配置文件:
docker run -d --name npc --restart=always --net=host ffdfgdfg/npc -server=<服务器IP:服务器通信端口> -vkey=<**key**y>
配置文件:docker run -d --name npc --net=host -v <本机conf目录>:/conf ffdfgdfg/npc -config=/conf/npc.conf
参数附在后面即可 请确保为conf文件夹下的npc.conf
查看日志docker logs npc
配置教程
Docker下修改输入即可
docker run -d --name npc --net=host ffdfgdfg/npc -server=0.0.0.0:8024 -vkey=myNPSkey
注册到系统服务(开机启动、守护进程)
对于linux、darwin
-
注册:
sudo ./npc install 其他参数(例如-server=xx -vkey=xx或者-config=xxx)
-
启动:
sudo npc start
-
停止:
sudo npc stop
-
如果需要更换命令内容需要先卸载
./npc uninstall
,再重新注册
对于windows,使用管理员身份运行cmd
- 注册:
npc.exe install 其他参数(例如-server=xx -vkey=xx或者-config=xxx)
- 启动:
npc.exe start
- 停止:
npc.exe stop
- 如果需要更换命令内容需要先卸载
npc.exe uninstall
,再重新注册
注册到服务后,日志文件windows位于当前目录下,linux和darwin位于/var/log/npc.log
客户端端配置文件 - npc.conf 详解
项 | 含义 |
---|---|
server_addr | 服务端ip/域名:port |
conn_type | 与服务端通信模式(tcp或kcp) |
vkey | 服务端配置文件中的密钥(非web) |
username | socks5或http(s)密码保护用户名(可忽略) |
password | socks5或http(s)密码保护密码(可忽略) |
compress | 是否压缩传输(true或false或忽略) |
crypt | 是否加密传输(true或false或忽略) |
rate_limit | 速度限制,可忽略 |
flow_limit | 流量限制,可忽略 |
remark | 客户端备注,可忽略 |
max_conn | 最大连接数,可忽略 |
pprof_addr | debug pprof ip:port |
健康检查
当客户端以配置文件模式启动时,支持多节点的健康检查。配置示例如下
[health_check_test1]
health_check_timeout=1
health_check_max_failed=3
health_check_interval=1
health_http_url=/
health_check_type=http
health_check_target=127.0.0.1:8083,127.0.0.1:8082
[health_check_test2]
health_check_timeout=1
health_check_max_failed=3
health_check_interval=1
health_check_type=tcp
health_check_target=127.0.0.1:8083,127.0.0.1:8082Copy to clipboardErrorCopied
health关键词必须在开头存在
第一种是http模式,也就是以get的方式请求目标+url,返回状态码为200表示成功
第一种是tcp模式,也就是以tcp的方式与目标建立连接,能成功建立连接表示成功
如果失败次数超过health_check_max_failed
,nps则会移除该npc下的所有该目标,如果失败后目标重新上线,nps将自动将目标重新加入。
项 | 含义 |
---|---|
health_check_timeout | 健康检查超时时间 |
health_check_max_failed | 健康检查允许失败次数 |
health_check_interval | 健康检查间隔 |
health_check_type | 健康检查类型 |
health_check_target | 健康检查目标,多个以逗号(,)分隔 |
health_check_type | 健康检查类型 |
health_http_url | 健康检查url,仅http模式适用 |
P2P内网穿透实例
想通过本机的2000端口---->访问到内网机器(内网IP)172.16.10.63的3389端口
(内网IP)172.16.10.63添加一条p2p代理,并设置唯一密钥(P2Pz)vmpwin10
在使用端机器(本机)执行命令
./npc -server=120.79.15.130:8024 -vkey=123 -password=vmpwin10 -target=172.16.10.63:3389 -local_port=2000
假设内网机器为172.16.10.63的ssh用户名为root,
现在在本机上执行ssh -p 2000 root@127.0.0.1即可访问机器2的ssh
如果是网站在浏览器访问127.0.0.1:2000端口即可。
[p2p_ssh]
local_port=2001
password=sambassh
target_addr=172.16.10.188:22