跳到主要内容

document

document​

docker-compose.yml​

services:
# ──────────────────────────────────────────────────────────────────
# ranuts/document:浏览器端 OnlyOffice 文档编辑器(DOCX/XLSX/PPTX)
# 官方镜像使用 static-web-server,不支持 clean URL(/editor → editor.html)
# 因此用 nginx 做反代补上映射,对外暴露 8090 端口
# ──────────────────────────────────────────────────────────────────
doc-editor:
image: ghcr.io/ranuts/document:latest
container_name: aidoc-doc-editor
restart: unless-stopped
# 不直接暴露到宿主机,仅在内网给 nginx/caddy 反代用
expose:
- "80"

# nginx 反代:补上 SWS 缺失的 /editor → editor.html 映射
doc-editor-proxy:
image: nginx:alpine
container_name: aidoc-doc-editor-proxy
restart: unless-stopped
ports:
- "8090:80"
volumes:
- ./data/doc-editor/nginx.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
- doc-editor

# ── 如果要用 Caddy 替代 nginx,注释掉上面的 doc-editor-proxy,改用下面的 ──
# doc-editor-proxy:
# image: caddy:2-alpine
# container_name: aidoc-doc-editor-proxy
# restart: unless-stopped
# ports:
# - "8090:8090"
# environment:
# - DOC_EDITOR_PORT=8090
# volumes:
# - ./doc-editor/Caddyfile:/etc/caddy/Caddyfile:ro
# depends_on:
# - doc-editor

nginx.conf​

server {
listen 80;
server_name _;

# /editor → editor.html(Vite 多入口构建产物)
location = /editor {
proxy_pass http://doc-editor:80/editor.html$is_args$args;
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;
}

# /history → history.html
location = /history {
proxy_pass http://doc-editor:80/history.html$is_args$args;
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;
}

# 其他所有请求直接转发给 static-web-server
location / {
proxy_pass http://doc-editor:80;
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;
}
}