惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Last Week in AI
Last Week in AI
D
DataBreaches.Net
腾讯CDC
Recent Announcements
Recent Announcements
有赞技术团队
有赞技术团队
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
罗磊的独立博客
月光博客
月光博客
MyScale Blog
MyScale Blog
U
Unit 42
Martin Fowler
Martin Fowler
Stack Overflow Blog
Stack Overflow Blog
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
G
Google Developers Blog
博客园 - 【当耐特】
D
Docker
I
InfoQ
雷峰网
雷峰网

博客园 - longbigfish

https证书问题(本地) 参数更新 Ubuntu 24安装Neo4j详细教程 protect 紧急 手机 刷脏页的两种模式 python中的多线程陷阱与pytorch分布式执行机制 git之复合指令和submodule rpc编程示例 mpi编程 cifs远程挂载 使用脚本进入一个命令行控制台,并预设执行的命令列表 cifs挂载远程文件出现 No such device or address错误 longtable 跨越多个页面时,如何在跨页时自动断行并加上横线及去掉页眉 matplotlib中文显示-微软雅黑 latex编译过程-关于嵌入所有字体 python做图笔记 linux启动全过程 连接并同步windows下的git仓库 反向ssh
部署(https证书)
longbigfish · 2026-04-13 · via 博客园 - longbigfish

1. 服务器安装docker

sudo apt update
sudo apt install -y docker.io docker-compose git

# 启动 Docker
sudo systemctl enable --now docker

# 免 sudo 使用 docker(需重新登录生效)
sudo usermod -aG docker $USER

2.  上传代码

3. 设置环境变量

4. 启动服务

3. 启动服务(需要sudo,或者将当前用户加入sudo)


直接 docker compose up -d --build  完成后就启动了

就能访问了

---代码同步

rsync -avz --exclude='node_modules' --exclude='__pycache__' --exclude='.git'  --exclude='data' /mnt/e/ts/xxx/ usr@ip:~/xxx/

-------- 这时候部署的是http,还需要改为https

1. 

第一步:安装 nginx 和 certbot
sudo apt install -y nginx certbot python3-certbot-nginx

2. 把 Docker 前端端口改为只监听本地


修改 docker-compose.yml,避免和宿主 nginx 冲突:
frontend:
ports: 
- "127.0.0.1:8080:80" # 改这行,只监听本地

重启容器:
docker-compose down && docker-compose up -d --build

3. 配置宿主机 nginx


sudo nano /etc/nginx/sites-available/tokenserve

内容:

server {
listen 80;
server_name xxx.com; # 换成你的域名

location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}

sudo ln -s /etc/nginx/sites-available/tokenserve /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx    --这一个提示没有运行,好像没关系(好像不行,关掉后就访问不了了)

4. 申请证书(自动配置 HTTPS)

 sudo certbot --nginx -d your-domain.com

 有新的需要证书的域名直接运行这个命令添加。使用  sudo certbot certificates 查看已有证书的域名

OK了,直接重新访问就是https了。

-------流程总结
1. docker-compose.yml里写了"127.0.0.1:8080:80",那么docker启动时就顺便在宿主机启动一个监听程序,监听8080端口,同时容器内部监听80端口
2. 宿主机nginx启动,监听80端口,由于配置了转发
http://127.0.0.1:8080
所以会将请求转到127.0.0.1:8080,这正是docker启动的监听,然后会映射到容器内的80端口。
3. 容器内会再次有个nginx(隶属于前端),负责进行前后端转发。