Nanbeige 4.1-3B部署教程Nginx反向代理HTTPS安全访问配置指南1. 项目概述与部署准备Nanbeige 4.1-3B是一款具有独特像素游戏风格的AI对话前端采用Streamlit框架开发。与传统AI界面不同它融入了JRPG视觉元素为用户带来沉浸式的复古冒险体验。1.1 系统要求硬件配置CPU4核以上内存16GB以上GPUNVIDIA显卡显存≥8GB存储至少20GB可用空间软件环境Ubuntu 20.04/22.04 LTSPython 3.8Docker 20.10Nginx 1.181.2 前置准备获取项目代码git clone https://github.com/your-repo/nanbeige-4.1-3B.git cd nanbeige-4.1-3B安装依赖pip install -r requirements.txt下载模型权重需提前申请权限wget https://model-repository/nanbeige-4.1-3B.tar.gz tar -xzvf nanbeige-4.1-3B.tar.gz2. 基础服务部署2.1 启动Streamlit应用创建启动脚本start_app.sh#!/bin/bash export STREAMLIT_SERVER_PORT8501 streamlit run app.py --server.headless true赋予执行权限并启动chmod x start_app.sh nohup ./start_app.sh app.log 21 2.2 验证服务运行检查服务是否正常启动curl http://localhost:8501预期输出应包含HTML格式的响应内容。如果遇到问题可查看日志文件app.log排查。3. Nginx反向代理配置3.1 安装Nginxsudo apt update sudo apt install nginx -y sudo systemctl start nginx3.2 配置反向代理创建Nginx配置文件/etc/nginx/conf.d/nanbeige.confserver { listen 80; server_name your-domain.com; location / { proxy_pass http://localhost:8501; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 流式响应支持 proxy_buffering off; proxy_request_buffering off; } # 静态资源缓存 location /static { alias /path/to/nanbeige-4.1-3B/static; expires 30d; } }测试配置并重载sudo nginx -t sudo systemctl reload nginx4. HTTPS安全配置4.1 获取SSL证书使用Certbot获取Lets Encrypt证书sudo apt install certbot python3-certbot-nginx -y sudo certbot --nginx -d your-domain.com4.2 更新Nginx配置自动生成的HTTPS配置基础上添加安全增强设置server { listen 443 ssl; server_name your-domain.com; ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem; # 安全协议配置 ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256...; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; # 其他配置与HTTP版本相同 ... }4.3 HTTP重定向到HTTPS添加重定向配置server { listen 80; server_name your-domain.com; return 301 https://$host$request_uri; }5. 高级配置与优化5.1 性能调优调整Nginx工作进程worker_processes auto; events { worker_connections 1024; multi_accept on; }添加Gzip压缩gzip on; gzip_types text/plain text/css application/json application/javascript; gzip_min_length 1024;5.2 安全加固配置安全头add_header X-Frame-Options SAMEORIGIN; add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection 1; modeblock; add_header Content-Security-Policy default-src self;限制请求大小client_max_body_size 10m; client_body_buffer_size 128k;6. 常见问题解决6.1 连接超时问题如果遇到504 Gateway Timeout调整代理超时设置proxy_connect_timeout 300s; proxy_send_timeout 300s; proxy_read_timeout 300s; send_timeout 300s;6.2 WebSocket支持如需支持WebSocket通信添加以下配置location /_stcore/stream { proxy_pass http://localhost:8501; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection upgrade; }6.3 证书自动续期设置自动续期任务sudo crontab -e # 添加以下内容 0 12 * * * /usr/bin/certbot renew --quiet7. 总结与后续维护通过本教程您已经完成了Nanbeige 4.1-3B的完整部署流程包括基础环境准备与Streamlit应用启动Nginx反向代理配置HTTPS安全访问设置性能优化与安全加固维护建议定期检查Nginx和Streamlit服务状态监控服务器资源使用情况及时更新SSL证书关注项目GitHub仓库获取更新获取更多AI镜像想探索更多AI镜像和应用场景访问 CSDN星图镜像广场提供丰富的预置镜像覆盖大模型推理、图像生成、视频生成、模型微调等多个领域支持一键部署。
Nanbeige 4.1-3B部署教程:Nginx反向代理+HTTPS安全访问配置指南
Nanbeige 4.1-3B部署教程Nginx反向代理HTTPS安全访问配置指南1. 项目概述与部署准备Nanbeige 4.1-3B是一款具有独特像素游戏风格的AI对话前端采用Streamlit框架开发。与传统AI界面不同它融入了JRPG视觉元素为用户带来沉浸式的复古冒险体验。1.1 系统要求硬件配置CPU4核以上内存16GB以上GPUNVIDIA显卡显存≥8GB存储至少20GB可用空间软件环境Ubuntu 20.04/22.04 LTSPython 3.8Docker 20.10Nginx 1.181.2 前置准备获取项目代码git clone https://github.com/your-repo/nanbeige-4.1-3B.git cd nanbeige-4.1-3B安装依赖pip install -r requirements.txt下载模型权重需提前申请权限wget https://model-repository/nanbeige-4.1-3B.tar.gz tar -xzvf nanbeige-4.1-3B.tar.gz2. 基础服务部署2.1 启动Streamlit应用创建启动脚本start_app.sh#!/bin/bash export STREAMLIT_SERVER_PORT8501 streamlit run app.py --server.headless true赋予执行权限并启动chmod x start_app.sh nohup ./start_app.sh app.log 21 2.2 验证服务运行检查服务是否正常启动curl http://localhost:8501预期输出应包含HTML格式的响应内容。如果遇到问题可查看日志文件app.log排查。3. Nginx反向代理配置3.1 安装Nginxsudo apt update sudo apt install nginx -y sudo systemctl start nginx3.2 配置反向代理创建Nginx配置文件/etc/nginx/conf.d/nanbeige.confserver { listen 80; server_name your-domain.com; location / { proxy_pass http://localhost:8501; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 流式响应支持 proxy_buffering off; proxy_request_buffering off; } # 静态资源缓存 location /static { alias /path/to/nanbeige-4.1-3B/static; expires 30d; } }测试配置并重载sudo nginx -t sudo systemctl reload nginx4. HTTPS安全配置4.1 获取SSL证书使用Certbot获取Lets Encrypt证书sudo apt install certbot python3-certbot-nginx -y sudo certbot --nginx -d your-domain.com4.2 更新Nginx配置自动生成的HTTPS配置基础上添加安全增强设置server { listen 443 ssl; server_name your-domain.com; ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem; # 安全协议配置 ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256...; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; # 其他配置与HTTP版本相同 ... }4.3 HTTP重定向到HTTPS添加重定向配置server { listen 80; server_name your-domain.com; return 301 https://$host$request_uri; }5. 高级配置与优化5.1 性能调优调整Nginx工作进程worker_processes auto; events { worker_connections 1024; multi_accept on; }添加Gzip压缩gzip on; gzip_types text/plain text/css application/json application/javascript; gzip_min_length 1024;5.2 安全加固配置安全头add_header X-Frame-Options SAMEORIGIN; add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection 1; modeblock; add_header Content-Security-Policy default-src self;限制请求大小client_max_body_size 10m; client_body_buffer_size 128k;6. 常见问题解决6.1 连接超时问题如果遇到504 Gateway Timeout调整代理超时设置proxy_connect_timeout 300s; proxy_send_timeout 300s; proxy_read_timeout 300s; send_timeout 300s;6.2 WebSocket支持如需支持WebSocket通信添加以下配置location /_stcore/stream { proxy_pass http://localhost:8501; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection upgrade; }6.3 证书自动续期设置自动续期任务sudo crontab -e # 添加以下内容 0 12 * * * /usr/bin/certbot renew --quiet7. 总结与后续维护通过本教程您已经完成了Nanbeige 4.1-3B的完整部署流程包括基础环境准备与Streamlit应用启动Nginx反向代理配置HTTPS安全访问设置性能优化与安全加固维护建议定期检查Nginx和Streamlit服务状态监控服务器资源使用情况及时更新SSL证书关注项目GitHub仓库获取更新获取更多AI镜像想探索更多AI镜像和应用场景访问 CSDN星图镜像广场提供丰富的预置镜像覆盖大模型推理、图像生成、视频生成、模型微调等多个领域支持一键部署。