-
-
Notifications
You must be signed in to change notification settings - Fork 357
How To: 30秒使用Linux搭建一个内网穿透服务端
TMOONLIGHT edited this page Mar 6, 2020
·
5 revisions
穿透的需要机器需要具备独立IP
下载最新版本的NSmartProxy服务端,如果是PC机上运行的则下载通用linux镜像即可:
wget https://github.com/tmoonlight/NSmartProxy/releases/download/v1.2_final/nspserver_scd_linux_v1.2.zip
如果运行在树莓派等等arm的板子上,请使用arm镜像
wget https://github.com/tmoonlight/NSmartProxy/releases/download/v1.2_final/nspserver_scd_linux_arm_v1.2.zip
解压,赋权,运行:
unzip nspserver_scd_linux_v1.2.zip
cd nspserver_scd_linux_v1.2
chmod +x ./NSmartProxy.ServerHost
./NSmartProxy.ServerHost
好了,30秒了,相信您已经运行起来服务端了:)
接下来您可能想要将NSmartProxy服务端注册为服务在后台运行,您可以先键入^+C停止上述服务,继续接下来的配置
下载supervisor服务管理工具
yum install supervisor
进入配置文件进行配置
sudo nano /etc/supervisord.conf
以下是配置文件,您只需要关注箭头部分:
; supervisor config file
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
; The [include] section can just contain the "files" setting. This
; setting can list multiple files (separated by whitespace or
; newlines). It can also contain wildcards. The filenames are
; interpreted as relative to this file. Included files *cannot*
; include files themselves.
[include]
files = /etc/supervisor/conf.d/*.conf ;<----改这里配置子进程配置文件,这里代表匹配所有conf.d下的conf文件
[inet_http_server]
port=*:6002 ;<----改这里配置管理后台端口
接下来配置子进程配置文件:
sudo mkdir ./conf.d
nano ./conf.d/nsmart.conf
以下是配置示例:
[program:nspserver]
command=/usr/nspserver_scd_linux_v1.2/NSmartProxy.ServerHost; <---执行命令
directory=/usr/nspserver_scd_linux_v1.2
environment=ASPNETCORE__ENVIRONMENT=Production
user=root
stopsignal=INT
autostart=true
autorestart=true
startsecs=1
stderr_logfile=/var/log/nspserver2.err.log
stdout_logfile=/var/log/nspserver2.out.log
最后一步
service supervisor restart
在supervisor的管理后台(http://IP:6002) 找到NSmartProxy服务端即告成功。