官网:https://nginxproxymanager.com/
docker官网:https://www.docker.com/
docker-compose安装:https://docs.docker.com/desktop/install/linux-install/
NginxProxyManager/nginx-proxy-manager项目地址:
https://github.com/NginxProxyManager/nginx-proxy-manager
xiaoxinpro/nginx-proxy-manager-zh汉化项目地址:
https://github.com/xiaoxinpro/nginx-proxy-manager-zh
添加SWAP虚拟内存(可选)
注意:VPS 的内存如果过小,建议设置一下 SWAP,一般为内存的 1-2 倍即可(1024-2048),可以让系统运行更流畅!
设置 SWAP 可以用脚本:
1
| wget -O box.sh https://raw.githubusercontent.com/BlueSkyXN/SKY-BOX/main/box.sh && chmod +x box.sh && clear && ./box.sh
|
升级 packages
1 2 3 4 5
| sudo -i
apt update -y
apt install wget curl sudo vim git -y
|
安装 Docker 环境
安装 Docker(非大陆服务器)
1 2 3 4 5
| wget -qO- get.docker.com | bash
docker -v
systemctl enable docker
|
安装 Docker(国内服务器)
1 2 3 4 5
| curl -sSL https://get.daocloud.io/docker | sh
docker -v
systemctl enable docker
|
安装docker-compose
1 2 3 4 5
| 非大陆 sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
大陆 sudo curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
|
添加可执行权限:x
1
| sudo chmod +x /usr/local/bin/docker-compose
|
在/usr/bin/路径下创建软连接
1
| ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
|
查看docker-compose版本
1
| docker-compose --version
|
安装 Nginx Proxy Manager
创建安装目录
1 2 3 4 5
| sudo -i
mkdir -p /root/data/docker_data/npm
cd /root/data/docker_data/npm
|
这边我们直接用 docker 的方式安装
配置docker-compose如下,监听80和443端口,81端口进后台
1 2 3 4 5 6 7 8 9 10 11 12
| version: '3.8' services: app: image: 'jc21/nginx-proxy-manager:latest' restart: unless-stopped ports: - '80:80' - '81:81' - '443:443' volumes: - ./data:/data - ./letsencrypt:/etc/letsencrypt
|
启动docker-compose
1 2 3
| cd /root/data/docker_data/npm
docker-compose up -d
|
启动docker-compose
默认登陆名和密码
Email:admin@example.com
Password:changeme
查看当前服务器IP
查看Docker容器内部IP:
Docker内部IP默认172.17.0.1
nginx proxy manager后台 0.0.0.0:81
更新 Nginx Proxy Manager
1 2 3 4 5 6 7 8 9 10 11
| cd /root/data/docker_data/npm
docker-compose down
cp -r /root/data/docker_data/npm /root/data/docker_data/npm.archive
docker-compose pull
docker-compose up -d
docker image prune
|
提示:
1 2
| WARNING! This will remove all dangling images. Are you sure you want to continue? [y/N]
|
卸载 Nginx Proxy Manager
1 2 3 4 5 6
| cd /root/data/docker_data/npm
docker-compose down
rm -rf /root/data/docker_data/npm
|
另附原版Nginx命令(与本篇NPM无关)
1 2 3 4 5 6
| sudo systemctl reload nginx & sudo nginx -s reload sudo systemctl restart nginx & sudo service nginx restart
sudo nginx -t
|