nginx-ai/README.md

66 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# nginx-ai
ash 服务器(`token.tlyq.ai`)的 nginx 反向代理配置Docker 部署。
## 架构
```
Internet (3 Mbps)
nginx:alpine (:80, :443)
├── token.tlyq.ai → proxy_pass → host.docker.internal:3000 (Go 后端)
├── token.tulingyinqing.com → proxy_pass → host.docker.internal:3000
└── *.tlyq.ai (default) → 阿里云 WAF 阻断
```
## 目录结构
```
nginx-ai/
├── docker-compose.yml # 容器定义nginx:alpine
├── nginx.conf # 主配置worker / events / http / proxy / ssl
├── conf.d/
│ ├── token-tlyq.conf # token.tlyq.ai server blockHTTP/2
│ ├── token-tuling.conf # token.tulingyinqing.com server block
│ └── letsencrypt.conf # HTTP→HTTPS 跳转 + acme-challenge
└── README.md
```
## 部署
```bash
git clone git@git.tlyq.ai:gaoxiaopei/nginx-ai.git /opt/nginx-ai
cd /opt/nginx-ai
docker compose up -d # 启动
docker compose restart # 重启
docker compose logs -f # 查看日志
```
## 证书
证书目录 `/etc/nginx/certs/tlyq.ai/` 不在本仓库(`.gitignore` 已排除)。
新服务器部署时需:
1. 从旧服务器复制证书目录,或
2. 重新申请 Let's Encrypt 证书(`certbot certonly --nginx -d *.tlyq.ai`
## 配置要点2026-07-14 优化)
| 配置项 | 优化前 | 优化后 |
|--------|:-----:|:-----:|
| `worker_processes` | 未设置(默认 1 | `auto`2 workers |
| `worker_connections` | 1024 | 4096 |
| `multi_accept` | 未设置 | `on` |
| HTTP/2 | 未启用 | `http2 on;` |
| `proxy_buffering` | 隐式默认 | 显式配置 |
## 修改配置后重载
```bash
docker compose restart
# 或热重载(不中断服务):
docker exec nginx-ai nginx -t
docker exec nginx-ai nginx -s reload
```