-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathnginx-reverse-proxy.conf
More file actions
70 lines (56 loc) · 2.62 KB
/
nginx-reverse-proxy.conf
File metadata and controls
70 lines (56 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# MarkItDown Website - Nginx 反向代理範本
#
# 適用場景:
# 使用 Docker 執行 MarkItDown Website 容器,前端以 Nginx 作為反向代理,
# 負責 SSL 終止、網域綁定,並將流量轉發至容器。
#
# 使用方式:
# 1. 將此檔案複製至 /etc/nginx/sites-available/markitdown
# 2. 修改 server_name 和 SSL 憑證路徑
# 3. 建立符號連結:ln -s /etc/nginx/sites-available/markitdown /etc/nginx/sites-enabled/
# 4. 測試設定:nginx -t
# 5. 重新載入:nginx -s reload
#
# 前置條件:
# - Docker 容器已啟動並監聽於 127.0.0.1:8080
# (docker compose up -d)
# - SSL 憑證已準備好(可使用 Certbot 申請 Let's Encrypt 免費憑證)
# sudo certbot --nginx -d your-domain.com
# ── HTTP:強制重新導向至 HTTPS ──────────────────────────────────────────────
server {
listen 80;
listen [::]:80;
server_name your-domain.com;
location / {
return 301 https://$host$request_uri;
}
}
# ── HTTPS:反向代理至 Docker 容器 ──────────────────────────────────────────
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name your-domain.com;
# SSL 憑證(請修改為實際路徑)
ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
# 建議的 SSL 安全設定
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 off;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1d;
# ── 反向代理至 Docker 容器 ─────────────────────────────────────────────
# COOP/COEP 安全標頭已由容器內的 Nginx 設定,代理層直接透傳即可。
location / {
proxy_pass http://127.0.0.1:8080;
# 標準代理標頭
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;
# 關閉代理緩衝,讓大型靜態資源(Pyodide WASM)直接串流
proxy_buffering off;
proxy_read_timeout 300s;
}
server_tokens off;
}