From e5442458a8cbb51a3a47eac64834d40e0f3dd978 Mon Sep 17 00:00:00 2001 From: chenos Date: Mon, 29 Apr 2024 19:45:31 +0800 Subject: [PATCH] fix: improve plugin static file proxy (#4227) --- packages/core/cli/nocobase.conf.tpl | 33 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/packages/core/cli/nocobase.conf.tpl b/packages/core/cli/nocobase.conf.tpl index 97d536287c..de25984e49 100644 --- a/packages/core/cli/nocobase.conf.tpl +++ b/packages/core/cli/nocobase.conf.tpl @@ -30,6 +30,26 @@ server { autoindex off; } + location {{publicPath}}static/plugins/ { + alias {{cwd}}/node_modules/; + expires 365d; + add_header Cache-Control "public"; + access_log off; + autoindex off; + + location ~ ^/static/plugins/@([^/]+)/([^/]+)/dist/client/(.*)$ { + allow all; + } + + location ~ ^/static/plugins/([^/]+)/dist/client/(.*)$ { + allow all; + } + + location ~ ^/static/plugins/(.*)$ { + deny all; + } + } + location {{publicPath}} { alias {{cwd}}/node_modules/@nocobase/app/dist/client/; try_files $uri $uri/ /index.html; @@ -58,19 +78,6 @@ server { send_timeout 600; } - location ^~ {{publicPath}}static/plugins/ { - proxy_pass http://127.0.0.1:{{apiPort}}{{publicPath}}static/plugins/; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection 'upgrade'; - proxy_set_header Host $host; - proxy_cache_bypass $http_upgrade; - proxy_connect_timeout 600; - proxy_send_timeout 600; - proxy_read_timeout 600; - send_timeout 600; - } - location {{publicPath}}ws { proxy_pass http://127.0.0.1:{{apiPort}}{{publicPath}}ws; proxy_http_version 1.1;