一直用FRP,配置簡單,使用簡單,比較穩定,但有時候也有抽風的事件發生,用NPS做個備用。
1、下載,因為我是linux環境,下載了linux對應的server和client,已編譯好,直接運行即可
https://github.com/ehang-io/nps/releases
https://github.com/ehang-io/nps/releases/download/v0.26.9/linux_amd64_client.tar.gz
https://github.com/ehang-io/nps/releases/download/v0.26.9/linux_amd64_server.tar.gz
2、部署
公網服務器部署server、內網服務器部署client
2.1、服務器配置
解壓后,直接修改配置文件,沒用的刪了,其它別動:
bridge 是服務端類型、地址、監聽端口,把端口改成自己的就行。
public_vkey是客戶端連接服務端認證用的,但是此處修改不生效,不知道為啥,不用管就行
web區塊,這兒是服務端web訪問的配置,看這配就行,官方說端口可以和bridge里一致,但實際測試發現不行,要兩個不同的端口,其它都沒用,默認就好
appname = nps #Boot mode(dev|pro) runmode = dev ##bridge bridge_type=tcp bridge_port=8888 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=/opt/nps/nps.log #web web_host=www.baidu.com web_username=admin web_password=666 web_port = 8889 web_ip=0.0.0.0 web_base_url= /nps 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 =1234567887654321 #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=true #pprof debug options #pprof_ip=0.0.0.0 #pprof_port=9999 #client disconnect timeout disconnect_timeout=60
2.2、客戶端配置
除了 server_addr 和服務端 bridge 配置一致外,其它不用動,把配置文件的其余部分刪了,配置也不起作用,這個版本測試發現必須從網頁上配
[common] server_addr=www.baidu.com:8888 conn_type=tcp vkey=123 auto_reconnection=true max_conn=1000 flow_limit=1000 rate_limit=1000 crypt=true compress=true disconnect_timeout=60
2.3、啟動服務端
./nps
2.4、服務端配置客戶端訪問
登錄服務端管理地址:www.baidu.com:8888 用配置的用戶名密碼登錄(admin:666)
在客戶端這兒新增就行:
然后可以對每個客戶端配置隧道。
客戶端連接用服務端給出的命令就行,點網頁上每個客戶端前面的+就能看到。
2.5、啟動客戶端
./npc -server=www.baidu.com:8888 vkey=8rehr93fwurfj04j -type=tcp
3、防止進程奔潰
在nps和npc同目錄下創建start.sh,內容如下:
cd $(dirname $0) pid=$(pgrep npc) if [ -z "$pid" ]; then nohup ./npc -server=www.baidu.com:8888 vkey=8rehr93fwurfj04j -type=tcp >/dev/null 2>&1 & fi
要記得:chmod a+x start.sh
要記得:*/10 * * * * root bash /opt/nps/start.sh