nps 内网穿透搭建
type
status
date
slug
summary
tags
category
icon
password
Property
Dec 5, 2022 11:04 AM
URL
这个是在 linux 上安装 nps
1. 安装
这是 GitHub项目地址
nps
ehang-io • Updated May 30, 2023
到 https://github.com/ehang-io/nps/releases 下载相应的版本,我的服务器是 64 位系统,x86 架构的,所以我下载 linux_amd64_server.tar.gz 这个,用 wget 命令获取
cd $HOME && mkdir nps && cd nps && wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_server.tar.gz
然后解压
tar -xvf linux_amd64_server.tar.gz
最后安装
sudo ./nps install
2. 服务端配置
安装好之后需要修改一下配置文件,因为默认启动 nps 是占用 80 端口的,这样会无法运行,所以我们需要修改配置
sudo vim /etc/nps/conf/nps.conf
下面这个是原始配置
appname = nps #Boot mode(dev|pro) runmode = dev #HTTP(S) proxy port, no startup if empty http_proxy_ip=0.0.0.0 http_proxy_port=80 https_proxy_port=443 https_just_proxy=true #default https certificate setting https_default_cert_file=conf/server.pem https_default_key_file=conf/server.key ##bridge bridge_type=tcp bridge_port=8024 bridge_ip=0.0.0.0 # Public password, which clients can use to connect to the server # After the connection, the server will be able to open relevant ports and parse related domain names according to its own configuration file. public_vkey=123 #Traffic data persistence interval(minute) #Ignorance means no persistence #flow_store_interval=1 # log level LevelEmergency->0 LevelAlert->1 LevelCritical->2 LevelError->3 LevelWarning->4 LevelNotice->5 LevelInformational->6 LevelDebug->7 log_level=7 #log_path=nps.log #Whether to restrict IP access, true or false or ignore #ip_limit=true #p2p #p2p_ip=127.0.0.1 #p2p_port=6000 #web web_host=a.o.com web_username=admin web_password=123 web_port = 8080 web_ip=0.0.0.0 web_base_url= web_open_ssl=false web_cert_file=conf/server.pem web_key_file=conf/server.key # if web under proxy use sub path. like http://host/nps need this. #web_base_url=/nps #Web API unauthenticated IP address(the len of auth_crypt_key must be 16) #Remove comments if needed #auth_key=test auth_crypt_key =1234567812345678 #allow_ports=9001-9009,10001,11000-12000 #Web management multi-user login allow_user_login=false allow_user_register=false allow_user_change_username=false #extension allow_flow_limit=false allow_rate_limit=false allow_tunnel_num_limit=false allow_local_proxy=false allow_connection_num_limit=false allow_multi_ip=false system_info_display=false #cache http_cache=false http_cache_length=100 #get origin ip http_add_origin_header=false #pprof debug options #pprof_ip=0.0.0.0 #pprof_port=9999 #client disconnect timeout disconnect_timeout=60
看起来有点长,说里面比较关键的几个东西
#HTTP(S) proxy port, no startup if empty
http_proxy_ip=0.0.0.0
http_proxy_port=80 这里的 80 修改成其他端口
https_proxy_port=443 443也最好修改成其他端口
https_just_proxy=true
#web
web_host=a.o.com
web_username=admin 这个是 web 页面的用户名
web_password=123 这个是 web 页面的 密码
web_port = 8080 这个是 web 页面的口
web_ip=0.0.0.0
web_base_url=
web_open_ssl=false
web_cert_file=conf/server.pem
web_key_file=conf/server.key
将以上几个红色部分修改就能启动了,
sudo nps start
最后使用
ip:8080
就能访问 web 页面了点击
客户端-新增


会给你一个客户端命令
./npc -server=你的ip:8024 -vkey=密钥 -type=tcp
但是我们后面用的时候需要做一些修改
sudo ./npc install -server=你的ip:8024 -vkey=密钥 -type=tcp
3. 客户端配置
我的客户端是 x86 架构 cpu,64 位系统,所以我下载 linux_amd64_client.tar.gz ,在客户端上面新建立一个 npc 文件夹,然后下载客户端
cd $HOME && mkdir npc && cd npc && wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_client.tar.gz
最后我们使用 无配置文件 方式
sudo ./npc install -server=你的ip:8024 -vkey=密钥 -type=tcp
启动
sudo npc start
如果需要重新配置什么的,就用
./npc uninstall
最后再重复上面的命令就行了