本文介绍NPS另一种的安装方式。
一、需要满足的条件
具有装好宝塔面板的公网IP的服务器一台,且安装好了Nginx服务,使其能够正常绑定网站。
怎么安装宝塔面板和Web服务器就不再多阐述了,详细请看官网教程。
二、获取SSH的root账号和密码
因为每个服务器厂商的获取方式不太一样,具体获取方式参考服务商官网教程。
三、使用终端工具安装wget服务
1.直接登录宝塔面板,点击左边的终端工具,使用下面的命令确认是否需要安装wget服务。
rpm -qa|grep "wget" //检查是否需要安装wget服务
如果显示有wget-1.14-18.el7_6.1.x86_64等字样就代表无需安装了!
2.如果没有安装wget服务,则输入以下命令安装即可。
yum -y install wget
yum -y install setup
yum -y install perl
四、安装NPS服务端
1.使用wget命令拉取NPS最新源码镜像,依然是在宝塔终端里进行操作。
国外服务器
wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_server.tar.gz
2.解压NPS到服务器目录
tar -xzvf linux_amd64_server.tar.gz
3.安装部署到服务器
sudo ./nps install
4.暂不启动NPS,因为和宝塔的端口存在冲突。
五、修改配置文件并启用nps服务
1.因为nps默认使用的TCP端口是80 443 8080 8024,宝塔面板的80 433 8080会被占用,因此这时候打不开nps的前端Web管理页面;我们需要修改nps的配置文件,后重新启动nps服务。
2.找到nps.conf文件,在宝塔面板中点击文件,切换到根目录的etc文件夹下,路径/etc/nps/conf/nps.conf。
3.使用文本编辑器打开(直接双击该文件)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 //80端口建议禁止注释掉,在宝塔面板上安装的nps不会用到
#https_proxy_port=443 //443端口建议禁止注释掉,在宝塔面板上安装的nps不会用到
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 //与npc客户端通讯的默认端口,建议修改为其他端口如:8424
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 //p2p代理要使用的端口,如果需要使用p2p代理服务,也可以修改一下端口
#web
web_host=a.o.com
web_username=admin //nps默认登录账号,建议更换为自己牢记的账号,如admin123
web_password=123 //nps默认登录密码,建议更换为自己牢记的密码,如admin123
web_port = 8080 //nps默认web管理页面访问端口,建议修改为其他端口如:9090
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
其他的TCP端口就不需要修改了,修改完成后保存进入下一个步骤,请牢记你修改的TCP端口,后续还会用到。
4.回到宝塔终端使用nps启动命令开启nps,启动后如修改配置文件需重启nps才会成功被应用,命令如下。
nps start //启动nps
nps stop //停止nps
sudo nps restart //重启nps
5.这个时候还需要放行以上你修改后的所有TCP端口,你的nps服务才能正常运行,直接去云服务器的防火墙里放行。
自此NPS服务端安装完毕,使用IP+端口进入NPS的管理页面