从零开始:NetBox 4.1 Docker 布置和晋级
前语
因为Netbox 官方的中文言语日渐完善,所以新出一个运用官方Docker源布置和晋级的教程。
Netbox 系列文章:https://songxwn.com/categories/NetBox/
环境介绍
Rocky Linux 9.5 (理论上也适用于RHEL系列的7-9版别)
南京大学镜像源ISO镜像下载:https://mirror.nju.edu.cn/rocky/9/isos/x86_64/Rocky-9-latest-x86_64-minimal.iso
环境装备
systemctl disable --now firewalld
sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config && setenforce 0
# 封闭防火墙和SELinux。
dnf install tree vim bash-completion tar git -y
# 装置一些东西,用于之后的布置
Docker-CE 环境装置
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sed -i 's+https://download.docker.com+https://mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
参阅清华大学源:https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/
Docker国内镜像加速器装备
sudo mkdir -p /etc/docker
# 创立文件夹
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://proxy.1panel.live",
"https://dockerpull.org",
"https://hub1.nat.tf",
"https://docker.m.daocloud.io"
]
}
EOF
# 指定镜像源
sudo systemctl daemon-reload
sudo systemctl restart docker
# 重载重启后收效
docker info | grep https
# 验证
docker pull hello-world
# 拉取镜像验证
PS: 或许参阅 https://songxwn.com/cf-works-DockerHub-Proxy/ 自行建立
Netbox布置
cd /opt
git clone -b release https://github.com/netbox-community/netbox-docker.git
# git获取官方库,国内可运用git clone -b release https://gitee.com/songxwn/netbox-docker.git
cd /opt/netbox-docker
tee docker-compose.override.yml <<EOF
services:
netbox:
ports:
- 8000:8080
EOF
# 创立端口映射规矩文件,运用8000端口对外拜访
docker compose pull
# 拉取镜像
docker compose up -d
# 发动镜像,第一次会比较久
docker compose logs netbox
# 检查日志,承认状况
创立用户(需求输入账号、邮箱和两次暗码)
docker compose exec netbox /opt/netbox/netbox/manage.py createsuperuser
## 等容器发动完成后,创立后可拜访 8000端口进行登录。
装备Nginx 作为反向署理
dnf install nginx -y
# 装置Nginx
vim /etc/nginx/conf.d/netbox.conf
# 创立装备文件,留意修正netbox.songxwn.com 为自己的域名。反向署理到8000端口,端口也需求自己修正。
server {
listen 80;
# CHANGE THIS TO YOUR SERVER'S NAME
server_name netbox.songxwn.com;
client_max_body_size 25m;
fastcgi_connect_timeout 1200s;
fastcgi_send_timeout 1200s;
fastcgi_read_timeout 1200s;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
location /static/ {
alias /opt/netbox/netbox/static/;
}
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
}
}
systemctl enable --now nginx
# 装备发动并开机发动
systemctl status nginx
# 检查状况
Netbox 晋级
cd /opt/netbox-docker
docker compose pull
# 拉最新镜像
docker compose down
docker compose up -d
# 以最新镜像重新发动
技术交流群
发送邮件到 ➡️ [email protected]
或许重视WX大众号:网工格物
博客(最早更新)
https://songxwn.com/