refactor: 去掉 top 顶层目录,镜像与部署编排直接放在仓库根下
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
# 证书不入库
|
||||
*.pem
|
||||
*.key
|
||||
@@ -0,0 +1,36 @@
|
||||
version: '3.8'
|
||||
|
||||
# 网桥 -> 方便相互通讯
|
||||
networks:
|
||||
tengine:
|
||||
ipam:
|
||||
driver: default
|
||||
config:
|
||||
- subnet: "172.25.0.0/24"
|
||||
|
||||
services:
|
||||
tengine:
|
||||
image: registry.cn-shanghai.aliyuncs.com/odboy/kenaito:proxy-tengine3 # 镜像由 build.sh 构建
|
||||
container_name: tengine # 容器名为'tengine'
|
||||
restart: unless-stopped
|
||||
ports: # 映射端口
|
||||
- "80:80" # http
|
||||
- "443:443" # https
|
||||
#- "8080:80" # 与其它 web 服务在同一台机器时改用此映射
|
||||
volumes: # 数据卷挂载路径设置,将本机目录映射到容器目录
|
||||
# 只挂载目录,不要单文件挂载 nginx.conf:单文件挂载在宿主机上编辑会触发 inode 变化,容器内看不到修改
|
||||
- "./nginx/conf.d:/usr/local/nginx/conf/conf.d"
|
||||
- "./nginx/ssl:/usr/local/nginx/conf/ssl"
|
||||
- "./nginx/html:/usr/local/nginx/html"
|
||||
- "./nginx/logs:/usr/local/nginx/logs"
|
||||
environment: # 设置环境变量,相当于docker run命令中的-e
|
||||
TZ: Asia/Shanghai
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "netstat -tln | grep -q ':80 ' && netstat -tln | grep -q ':443 '"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 5s
|
||||
networks:
|
||||
tengine:
|
||||
ipv4_address: 172.25.0.20
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
docker-compose -f docker-compose.yml -p tengine up -d
|
||||
@@ -0,0 +1,45 @@
|
||||
# demo.odboy.cn -> http
|
||||
server {
|
||||
listen 80;
|
||||
server_name demo.odboy.cn;
|
||||
|
||||
access_log /dev/stdout main;
|
||||
|
||||
location / {
|
||||
root /usr/local/nginx/html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
# 反向代理到 HTTP 服务(同一 docker 网络中直接用服务名:端口,例如下面 nacos 的写法)
|
||||
#location /api/ {
|
||||
# proxy_pass http://172.25.0.21:8848/;
|
||||
# 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_set_header X-Forwarded-Proto $scheme;
|
||||
#}
|
||||
}
|
||||
|
||||
# demo.odboy.cn -> https
|
||||
server {
|
||||
listen 443 ssl;
|
||||
http2 on;
|
||||
server_name demo.odboy.cn;
|
||||
|
||||
access_log /dev/stdout main;
|
||||
|
||||
# 证书放在 ./nginx/ssl 下,挂载到 /usr/local/nginx/conf/ssl
|
||||
ssl_certificate /usr/local/nginx/conf/ssl/demo.odboy.cn.pem;
|
||||
ssl_certificate_key /usr/local/nginx/conf/ssl/demo.odboy.cn.key;
|
||||
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_timeout 10m;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
location / {
|
||||
root /usr/local/nginx/html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>tengine</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3>tengine 3.1.0 is running</h3>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,3 @@
|
||||
# 日志统一输出到 stdout,此目录仅作备用
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,3 @@
|
||||
# 证书不入库
|
||||
*.pem
|
||||
*.key
|
||||
@@ -0,0 +1,67 @@
|
||||
# Tengine 3.1.0
|
||||
|
||||
基于 alinux3 源码编译的 Tengine 3.1.0 反向代理 / Web 服务器,镜像由同目录 `build.sh` 构建(
|
||||
`registry.cn-shanghai.aliyuncs.com/odboy/kenaito:proxy-tengine3`)
|
||||
|
||||
- https://tengine.taobao.org
|
||||
- 以 root 启动,worker 进程自动降权;日志输出到 stdout/stderr,交给 docker 日志驱动收集
|
||||
- 编译参数见 `Dockerfile`,默认配置文件见 `nginx.conf`(`user root`、`worker_processes auto`、`access_log /dev/stdout`、
|
||||
`include conf.d/*.conf`)
|
||||
|
||||
### 目录映射
|
||||
|
||||
| 宿主机 | 容器 | 说明 |
|
||||
|------------------|--------------------------------|----------------------------|
|
||||
| `./nginx/conf.d` | `/usr/local/nginx/conf/conf.d` | 站点配置,`*.conf` 被主配置 include |
|
||||
| `./nginx/ssl` | `/usr/local/nginx/conf/ssl` | https 证书(`*.pem`、`*.key`) |
|
||||
| `./nginx/html` | `/usr/local/nginx/html` | 静态资源 |
|
||||
| `./nginx/logs` | `/usr/local/nginx/logs` | 备用日志目录(实际访问日志已输出到 stdout) |
|
||||
|
||||
`nginx.conf` 本身没有挂载:如需修改主配置,建议 `docker cp` 出来改好后 `docker commit`/重新构建,避免单文件挂载导致宿主机编辑后容器内不生效
|
||||
|
||||
### 部署方式
|
||||
|
||||
```shell
|
||||
docker build -t registry.cn-shanghai.aliyuncs.com/odboy/kenaito:proxy-tengine3 .
|
||||
sh install.sh
|
||||
```
|
||||
|
||||
等同:`docker-compose -f docker-compose.yml -p tengine up -d`
|
||||
|
||||
访问 http://192.168.235.104 (http 80)、https://192.168.235.104 (https 443),
|
||||
如 `demo.odboy.cn` 已解析到该机器,可用 `-H "Host: demo.odboy.cn"` 或直接访问域名
|
||||
|
||||
### 常用命令
|
||||
|
||||
```shell
|
||||
# 查看日志(访问/错误日志均走 stdout/stderr)
|
||||
docker logs -f tengine
|
||||
|
||||
# 修改 conf.d 下的站点配置后,先校验再平滑重载(不中断连接)
|
||||
docker exec tengine nginx -t
|
||||
docker exec tengine nginx -s reload
|
||||
|
||||
# 查看编译模块
|
||||
docker exec tengine nginx -V
|
||||
```
|
||||
|
||||
### 请求本容器之前挂了 Nacos / 其它服务?
|
||||
|
||||
`demo.odboy.cn.conf` 中已经给出了反向代理写法注释,同一网段内可直接用 IP 或服务名:
|
||||
|
||||
```nginx
|
||||
location /api/ {
|
||||
proxy_pass http://172.25.0.21:8848/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
```
|
||||
|
||||
若需要容器名互通,把其它服务的 `container_name` 加入同一网络 `tengine`,或直接用上面固定的 `ipv4_address`
|
||||
|
||||
### 停止
|
||||
|
||||
```shell
|
||||
sh shutdown.sh # docker-compose -f docker-compose.yml -p tengine down
|
||||
```
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
docker-compose -f docker-compose.yml -p tengine down
|
||||
Reference in New Issue
Block a user