From 6e8781e0e69732521da8a5455e4dd1d718402f2a Mon Sep 17 00:00:00 2001
From: balibabu <cike8899@users.noreply.github.com>
Date: Wed, 28 Feb 2024 17:36:44 +0800
Subject: [PATCH] feat: add nginx.conf (#80)

* feat: add nginx.conf

* feat: modify the root path of the web
---
 docker/nginx.conf | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 web/.umirc.ts     |  2 +-
 2 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100644 docker/nginx.conf

diff --git a/docker/nginx.conf b/docker/nginx.conf
new file mode 100644
index 0000000..af83a61
--- /dev/null
+++ b/docker/nginx.conf
@@ -0,0 +1,46 @@
+upstream api_service {
+    server 127.0.0.1:9380;
+    keepalive 2000;
+}
+
+server {
+    listen 5101;
+    # server_name xxx.com;
+
+    # gzip config
+    gzip on;
+    gzip_min_length 1k;
+    gzip_comp_level 9;
+    gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
+    gzip_vary on;
+    gzip_disable "MSIE [1-6]\.";
+
+
+    # remove api server header
+    proxy_hide_header Access-Control-Allow-Origin;
+    proxy_hide_header Access-Control-Allow-Methods;
+    proxy_hide_header Access-Control-Allow-Headers;
+
+    root /ragflow/web/dist;
+
+    location / {
+        index index.html;
+        try_files $uri $uri/ /index.html;
+    }
+
+    # Cache-Control: max-age、Expires
+    location ~ ^/static/(css|js|media)/ {
+        expires 10y;
+        access_log off;
+    }
+
+    # api proxy
+    location ^~/v1 {
+        rewrite ^/v1/(.*)$ /$1 break;
+        proxy_pass http://api_service/;
+        proxy_set_header Host $http_host;
+        proxy_set_header Connection close;
+        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header X-Forwarded-Server $host;
+    }
+}
\ No newline at end of file
diff --git a/web/.umirc.ts b/web/.umirc.ts
index 2d66b3c..ec05621 100644
--- a/web/.umirc.ts
+++ b/web/.umirc.ts
@@ -7,7 +7,7 @@ export default defineConfig({
   npmClient: 'npm',
   base: '/',
   routes,
-  publicPath: '/web/dist/',
+  publicPath: '/',
   esbuildMinifyIIFE: true,
   icons: {},
   hash: true,
-- 
GitLab