fix: 修复工具nginx反代路径冲突
- Stirling PDF: 使用 SERVER_SERVLET_CONTEXT_PATH=/pdf 从根本解决 base href 问题 - TrWebOCR: 用精确文件名 location 代替 sub_filter(后端 gzip 导致 sub_filter 不生效) - Lama Cleaner: 同样用精确 location 匹配所有 API 路径(/model, /inpaint 等) - PDF API 用 /api/v1/ 精确匹配,和 imgcompress 的 /api/ 不冲突 - OCR API 用 /api/tr-run/ 精确匹配 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,23 +2,17 @@ server {
|
||||
listen 18000;
|
||||
client_max_body_size 500M;
|
||||
|
||||
# 1. Stirling PDF
|
||||
# ===== 1. Stirling PDF =====
|
||||
# <base href="/"> 导致相对路径从根开始,用sub_filter改成/pdf/
|
||||
# context-path=/pdf,所有PDF资源都在 /pdf/ 下,无冲突
|
||||
location /pdf/ {
|
||||
proxy_pass http://127.0.0.1:18080/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header Accept-Encoding "";
|
||||
proxy_buffering off;
|
||||
sub_filter_once off;
|
||||
sub_filter '"/api/' '"/pdf-api/';
|
||||
}
|
||||
location /pdf-api/ {
|
||||
proxy_pass http://127.0.0.1:18080/api/;
|
||||
proxy_pass http://127.0.0.1:18080/pdf/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_buffering off;
|
||||
client_max_body_size 500M;
|
||||
}
|
||||
|
||||
# 2. Excalidraw
|
||||
# ===== 2. Excalidraw =====
|
||||
location /draw/ {
|
||||
proxy_pass http://127.0.0.1:18081/;
|
||||
proxy_set_header Host $host;
|
||||
@@ -31,20 +25,41 @@ server {
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
# 3. TrWebOCR
|
||||
# ===== 3. TrWebOCR =====
|
||||
# 不用 sub_filter(后端返回 gzip 无法改写),直接用精确文件名 location
|
||||
location /ocr/ {
|
||||
proxy_pass http://127.0.0.1:18083/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_buffering off;
|
||||
}
|
||||
# OCR 的 JS/CSS(精确文件名,不会和 Overleaf 冲突)
|
||||
location /js/app.7dd3e457.js { proxy_pass http://127.0.0.1:18083/js/app.7dd3e457.js; }
|
||||
location /js/chunk-vendors.ae13d15d.js { proxy_pass http://127.0.0.1:18083/js/chunk-vendors.ae13d15d.js; }
|
||||
location /css/app.77d50329.css { proxy_pass http://127.0.0.1:18083/css/app.77d50329.css; }
|
||||
location /css/chunk-vendors.9d96bc97.css { proxy_pass http://127.0.0.1:18083/css/chunk-vendors.9d96bc97.css; }
|
||||
# OCR 的 API
|
||||
location /api/tr-run/ {
|
||||
proxy_pass http://127.0.0.1:18083/api/tr-run/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_buffering off;
|
||||
client_max_body_size 50M;
|
||||
}
|
||||
location /tools/ocr_text/ {
|
||||
proxy_pass http://127.0.0.1:18083/tools/ocr_text/;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
# 4. LibreTranslate
|
||||
# ===== 4. LibreTranslate =====
|
||||
location /translate/ {
|
||||
proxy_pass http://127.0.0.1:18084/;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
location /static/ { proxy_pass http://127.0.0.1:18084/static/; }
|
||||
location /languages { proxy_pass http://127.0.0.1:18084/languages; }
|
||||
location /frontend/settings { proxy_pass http://127.0.0.1:18084/frontend/settings; }
|
||||
location /detect { proxy_pass http://127.0.0.1:18084/detect; }
|
||||
|
||||
# 5. PPTist
|
||||
# ===== 5. PPTist =====
|
||||
location /ppt/ {
|
||||
proxy_pass http://127.0.0.1:18085/;
|
||||
proxy_set_header Host $host;
|
||||
@@ -58,38 +73,11 @@ server {
|
||||
proxy_cache off;
|
||||
}
|
||||
|
||||
# 6. imgcompress
|
||||
# ===== 6. imgcompress =====
|
||||
location /imgcompress/ {
|
||||
proxy_pass http://127.0.0.1:18087/;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
# 7. Lama Cleaner
|
||||
location /lama/ {
|
||||
proxy_pass http://127.0.0.1:18088/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_buffering off;
|
||||
}
|
||||
location /lama/inpaint {
|
||||
proxy_pass http://127.0.0.1:18088/inpaint;
|
||||
proxy_set_header Host $host;
|
||||
proxy_buffering off;
|
||||
proxy_read_timeout 300s;
|
||||
client_max_body_size 500M;
|
||||
}
|
||||
# Lama Cleaner 的2个精确static文件
|
||||
location /static/js/main.1bd455bc.js { proxy_pass http://127.0.0.1:18088/static/js/main.1bd455bc.js; }
|
||||
location /static/css/main.c28d98ca.css { proxy_pass http://127.0.0.1:18088/static/css/main.c28d98ca.css; }
|
||||
|
||||
# /static/ 其余的给 LibreTranslate
|
||||
location /static/ { proxy_pass http://127.0.0.1:18084/static/; }
|
||||
|
||||
# LibreTranslate 绝对路径 API
|
||||
location /languages { proxy_pass http://127.0.0.1:18084/languages; }
|
||||
location /frontend/settings { proxy_pass http://127.0.0.1:18084/frontend/settings; }
|
||||
location /detect { proxy_pass http://127.0.0.1:18084/detect; }
|
||||
|
||||
# imgcompress 绝对路径
|
||||
location /_next/ { proxy_pass http://127.0.0.1:18087/_next/; }
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:18087/api/;
|
||||
@@ -98,14 +86,40 @@ server {
|
||||
client_max_body_size 500M;
|
||||
}
|
||||
|
||||
# 8. webp2jpg
|
||||
# ===== 7. Lama Cleaner =====
|
||||
# sub_filter 不生效(后端 gzip),用精确 location 匹配所有 API 和静态资源
|
||||
location /lama/ {
|
||||
proxy_pass http://127.0.0.1:18088/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_buffering off;
|
||||
}
|
||||
# Lama 静态资源(精确文件名)
|
||||
location = /static/js/main.1bd455bc.js { proxy_pass http://127.0.0.1:18088/static/js/main.1bd455bc.js; }
|
||||
location = /static/css/main.c28d98ca.css { proxy_pass http://127.0.0.1:18088/static/css/main.c28d98ca.css; }
|
||||
# Lama API(全部用精确路径)
|
||||
location = /inpaint {
|
||||
proxy_pass http://127.0.0.1:18088/inpaint;
|
||||
proxy_set_header Host $host;
|
||||
proxy_buffering off;
|
||||
proxy_read_timeout 300s;
|
||||
client_max_body_size 500M;
|
||||
}
|
||||
location = /inputimage { proxy_pass http://127.0.0.1:18088/inputimage; proxy_set_header Host $host; proxy_buffering off; }
|
||||
location = /model { proxy_pass http://127.0.0.1:18088/model; proxy_set_header Host $host; }
|
||||
location = /is_desktop { proxy_pass http://127.0.0.1:18088/is_desktop; }
|
||||
location = /is_disable_model_switch { proxy_pass http://127.0.0.1:18088/is_disable_model_switch; }
|
||||
location = /is_enable_file_manager { proxy_pass http://127.0.0.1:18088/is_enable_file_manager; }
|
||||
location = /interactive_seg { proxy_pass http://127.0.0.1:18088/interactive_seg; proxy_set_header Host $host; }
|
||||
location = /save_image { proxy_pass http://127.0.0.1:18088/save_image; proxy_set_header Host $host; client_max_body_size 500M; }
|
||||
|
||||
# ===== 8. webp2jpg =====
|
||||
location /webp2jpg/ {
|
||||
proxy_pass http://127.0.0.1:18089/;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
location /cdn/ { proxy_pass http://127.0.0.1:18089/cdn/; }
|
||||
|
||||
# 9. Overleaf
|
||||
# ===== 9. Overleaf =====
|
||||
location /overleaf/ {
|
||||
proxy_pass http://127.0.0.1:18090/;
|
||||
proxy_set_header Host $host;
|
||||
@@ -115,13 +129,13 @@ server {
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
# 10. LaTeX 公式编辑器
|
||||
# ===== 10. LaTeX 公式编辑器 =====
|
||||
location /latex/ {
|
||||
proxy_pass http://127.0.0.1:18091/;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
# 默认回落到 Overleaf
|
||||
# ===== 默认回落到 Overleaf =====
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:18090;
|
||||
proxy_set_header Host $host;
|
||||
|
||||
Reference in New Issue
Block a user