一、NPS 概述
NPS 是一款轻量级、功能强大的内网穿透代理服务器。支持 tcp、udp 流量转发,支持内网 http 代理、内网 socks5 代理,同时支持 snappy 压缩、站点保护、加密传输、多路复用、header 修改等。支持 web 图形化管理,集成多用户模式。管理系统比 FRP 方便很多,更容易上手。
二、配置要求
- 一台拥有公网 IP 的服务器
- 开放端口例如:(8080,8024,80,443)等
- 安装 nps 软件包(源码安装、linux、darwin、windows)几种系统安装方法
三、相关文档
- NPS 配置文档:https://ehang-io.github.io/nps/#/
- NPS 安装包:https://github.com/ehang-io/nps/releases
- NPS 源码:https://github.com/ehang-io/nps
四、环境说明
演示环境以 Linux 为例,如大家需要 window 或 Mac 系统演示安装,请留言,后期更新到本文档。
服务端环境,阿里云服务 CentOS7.3 客户端环境,16 年退休老电脑 Deepin20 安装包下载,Github 下载有时较慢,可通过下面加速链接下载。
下载服务端文件链接: linux_amd64_server.tar.gz
下载客户端链接: linux_amd64_client.tar.gz
五、服务端安装
安装命令
mkdir ~/nps
wget -O ~/nps/linux_amd64_server.tar.gz https://ghproxy.com/https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_server.tar.gz && cd ~/nps && tar zxvf linux_amd64_server.tar.gz
cd nps
nano 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 install -config=/root/nps/conf/nps.conf
./nps start
#重载配置文件/重启/停止服务端
./nps reload|restart|stop卸载服务
./nps uninstall然后打开地址http://ip:8080访问管理界面,具体端口以自己修改的为准,再使用密码登录进去,默认为123。

六、客户端安装
安装命令
mkdir ~/nps
wget -O ~/nps/linux_amd64_client.tar.gz https://ghproxy.com/https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_client.tar.gz && cd ~/nps && tar zxvf linux_amd64_client.tar.gz
nano conf/npc.conf启动
nohup ./npc -server=(ip:port) -vkey=(见演示中服务端后管界面中显示的密钥)
注册到系统服务(开机启动、守护进程)
./npc install -config=/root/npc/conf/npc.conf
./npc start卸载
cd /root/nps/
./npc uninstall七、配置文件说明
全局配置
[common]
server_addr=1.1.1.1:8024
conn_type=tcp
vkey=123
username=111
password=222
compress=true
crypt=true
rate_limit=10000
flow_limit=100
remark=test
max_conn=10
#pprof_addr=0.0.0.0:9999| 项 | 含义 |
|---|---|
| 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 |
域名代理
[common]
server_addr=1.1.1.1:8024
vkey=123
[web1]
host=a.proxy.com
target_addr=127.0.0.1:8080,127.0.0.1:8082
host_change=www.proxy.com
header_set_proxy=nps| 项 | 含义 |
|---|---|
| web1 | 备注 |
| host | 域名(http |
| target_addr | 内网目标,负载均衡时多个目标,逗号隔开 |
| host_change | 请求host修改 |
| header_xxx | 请求header修改或添加,header_proxy表示添加header proxy:nps |
tcp隧道模式
[common]
server_addr=1.1.1.1:8024
vkey=123
[tcp]
mode=tcp
target_addr=127.0.0.1:8080
server_port=9001| 项 | 含义 |
|---|---|
| mode | tcp |
| server_port | 在服务端的代理端口 |
| tartget_addr | 内网目标 |
udp隧道模式
[common]
server_addr=1.1.1.1:8024
vkey=123
[udp]
mode=udp
target_addr=127.0.0.1:8080
server_port=9002| 项 | 含义 |
|---|---|
| mode | udp |
| server_port | 在服务端的代理端口 |
| target_addr | 内网目标 |
http代理模式
[common]
server_addr=1.1.1.1:8024
vkey=123
[http]
mode=httpProxy
server_port=9003| 项 | 含义 |
|---|---|
| mode | httpProxy |
| server_port | 在服务端的代理端口 |
socks5代理模式
[common]
server_addr=1.1.1.1:8024
vkey=123
[socks5]
mode=socks5
server_port=9004
multi_account=multi_account.conf| 项 | 含义 |
|---|---|
| mode | socks5 |
| server_port | 在服务端的代理端口 |
| multi_account | socks5多账号配置文件(可选),配置后使用basic_username和basic_password无法通过认证 |
私密代理模式
[common]
server_addr=1.1.1.1:8024
vkey=123
[secret_ssh]
mode=secret
password=ssh2
target_addr=10.1.50.2:22| 项 | 含义 |
|---|---|
| mode | secret |
| password | 唯一密钥 |
| target_addr | 内网目标 |
p2p代理模式
[common]
server_addr=1.1.1.1:8024
vkey=123
[p2p_ssh]
mode=p2p
password=ssh2
target_addr=10.1.50.2:22| 项 | 含义 |
|---|---|
| mode | p2p |
| password | 唯一密钥 |
| target_addr | 内网目标 |
文件访问模式
利用nps提供一个公网可访问的本地文件服务,此模式仅客户端使用配置文件模式方可启动
[common]
server_addr=1.1.1.1:8024
vkey=123
[file]
mode=file
server_port=9100
local_path=/tmp/
strip_pre=/web/| 项 | 含义 |
|---|---|
| mode | file |
| server_port | 服务端开启的端口 |
| local_path | 本地文件目录 |
| strip_pre | 前缀 |
对于strip_pre,访问公网ip:9100/web/相当于访问/tmp/目录
断线重连
[common]
auto_reconnection=true更多配置
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。




























































