docker部署nps、npm实现加密穿透
安装docker环境
1、使用kejilion脚本安装
apt update -y && apt install -y curl socat wget sudo
curl -fsSL https://get.docker.com | sh && ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/local/bin
2、更改debain的安装源
cd /etc/apt/sources.list.d
vim mysources.list
#将下面链接拷贝到文件中保存
deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian-secu... stretch/updates main
deb-src http://mirrors.aliyun.com/debian-secu... stretch/updates main
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
#更新系统
apt update
#centos7安装docker及docker-compose(见文档)
需要安装docker加速器
使用docker-compose安装npm
mkdir -p /root/docker/npm
cd /root/docker/npm
vim docker-compose.yml
version: '3.8'
services:
npm:
#image: 'jc21/nginx-proxy-manager:latest' # 官方
image: 'chishin/nginx-proxy-manager-zh:latest' # 汉化
restart: unless-stopped
container_name: 'npm'
network_mode: bridge
ports: # 请确定放行以下端口
- '80:80'
- '81:81'
- '443:443'
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
lsof - i:端口 #使用工具查看端口占用情况,如果没有命令需要安装
docker compose up -d #需要在npm文件夹内执行
#运行之后 可以使用ip:81访问网页访问初始用户名密码
Email: admin@example.com
Password: changeme
#运行后不能进入出现bad gateway 需要进入容器更改一下
docker exec -it 容器id /bin/bash
#进入容器后需要使用apt-get update更新系统后,使用apt install -y vim 安装编辑器
#解决办法:我看issue里面的大概直接粗暴的帮 /app/index.js里面的 .then(internalIpRanges.fetch) 给删掉了。
.then(() => {
return apiValidator.loadSchemas;
})
//.then(internalIpRanges.fetch) #将本行注释掉
.then(() => {
internalCertificate.initTimer();
更新版本
cd /root/docker/npm
docker compose down #版本不同使用的命令不一样,docker-compose中间的-直接不用
cp -r /root/docker/npm /root/docker/npm.archive # 万事先备份,以防万一
docker compose pull
docker compose up -d # 请不要使用 docker-compose stop 来停止容器,因为这么做需要额外的时间等待容器停止;docker-compose up -d 直接升级容器时会自动停止并立刻重建新的容器,完全没有必要浪费那些时间。
docker image prune # prune 命令用来删除不再使用的 docker 对象。删除所有未被 tag 标记和未被容器使用的镜像
卸载npm
cd /root/docker/npm
docker-compose down
rm -rf /root/docker/npm # 完全删除映射到本地的数据
docker 配置(可选)
以下配置会增加一段自定义内网 IPv6 地址,开启容器的 IPv6 功能,以及限制日志文件大小,防止 Docker 日志塞满硬盘(泪的教训):
cat > /etc/docker/daemon.json <<EOF
{
"log-driver": "json-file",
"log-opts": {
"max-size": "20m",
"max-file": "3"
},
"ipv6": true,
"fixed-cidr-v6": "fd00:dead:beef:c0::/80",
"experimental":true,
"ip6tables":true
}
EOF
使用docker-compose安装nps
mkdir -p /root/docker/nps
cd /root/docker/nps
vim docker-compose.yml
name: nps
services:
nps:
container_name: nps
network_mode: host
restart: always
volumes:
- /root/docker/nps/conf:/conf #最前面的目录必须正确 将nps官网下载的conf文件拷贝到目录内
image: ffdfgdfg/nps
修改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访问的用户名
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
# 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 bitwarden
#pprof_port=9999
#client disconnect timeout
disconnect_timeout=60
部署
docker compose up -d
lsof -i:8080 #查询端口如果被占用则证明搭建成功
使用ip:8080就可以访问了,用户名和密码为nps.conf中设置的那个。
#客户端搭建教程,使用docker搭建,下面中标*为更改项,在nps服务器中可以找到
docker run -d --name npc --net=host --restart=always ffdfgdfg/npc -server=*nps.mjvlog.top:8024* -vkey=*g4x0yw778uomt6n8*
以上docker需要安装加速器。
版权声明:
本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自
痕迹!
喜欢就支持一下吧