部署架构
公网服务器A,负载均衡B,内网服务器C
在A上安装nps的服务端,并通过B访问nps服务。
服务端
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=
https_proxy_port=
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=${YOUR_BRIDGE_PORT}
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=${YOUR_PUBLIC_VKEY}
#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=
web_username=npsadmin
web_password=${YOUR_ADMIN_PASSWORD}
web_port = ${YOUR_WEB_PORT}
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 =${YOUR_AUTH_CRYPT_KEY}
#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
YOUR_BRIDGE_PORT 是nps服务的端口,可以通过负载均衡B创建监听转发tcp到此端口。
YOUR_WEB_PORT 是nps后台的端口,可以通过负载均衡B的https监听创建转发策略转发域名到此端口。
使用SSH
连接nps后台,创建客户端和通道。创建通道时的端口【通道端口】,是A服务器上的某个开放端口,表示通过此端口和对应的客户端建立连接。
客户端
./npc -server=ip:port -vkey=vkey -type=tcp
# 安装为系统服务
./npc install -server=ip:port -vkey=vkey -type=tcp
service npc start/stop
ip是A的ip,则端口是YOUR_BRIDGE_PORT。ip是B的ip,则端口是负载均衡B的监听端口。
客户端启动后,在其它任意电脑上使用:
ssh user@ip -P 【通道端口】
通过此命令连接到C。
在C上,可以通过B来转发A的ssh,加速C访问A。(C是可以直接访问A的,但是A的带宽可能不足,通过B来转发能加快速度)。这要求C能访问B的转发端口。