From 79fd4ec58f08a532b25e1cc9ba0dd6cec1180e87 Mon Sep 17 00:00:00 2001 From: whyour Date: Fri, 26 May 2023 17:08:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20nginx=20=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/front.conf | 3 ++- shell/share.sh | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docker/front.conf b/docker/front.conf index 3107966f..b528beb8 100644 --- a/docker/front.conf +++ b/docker/front.conf @@ -51,9 +51,10 @@ server { gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.0; + QL_ROOT_CONFIG location QL_BASE_URL_LOCATION { - QL_ROOT_OR_ALIAS /ql/static/dist; + QL_ALIAS_CONFIG index index.html index.htm; try_files $uri QL_BASE_URLindex.html; } diff --git a/shell/share.sh b/shell/share.sh index cccdd052..b67f0b76 100755 --- a/shell/share.sh +++ b/shell/share.sh @@ -468,14 +468,18 @@ init_nginx() { cp -fv $nginx_conf /etc/nginx/nginx.conf cp -fv $nginx_app_conf /etc/nginx/conf.d/front.conf local location_url="/" - local root_or_alias="root" + local aliasStr="" + local rootStr="" if [[ $ql_base_url != "/" ]]; then location_url="^~${ql_base_url%*/}" - root_or_alias="alias" + aliasStr="alias ${dir_static}/dist;" + else + rootStr="root ${dir_static}/dist;" fi + sed -i "s,QL_ALIAS_CONFIG,${aliasStr},g" /etc/nginx/conf.d/front.conf + sed -i "s,QL_ROOT_CONFIG,${rootStr},g" /etc/nginx/conf.d/front.conf sed -i "s,QL_BASE_URL_LOCATION,${location_url},g" /etc/nginx/conf.d/front.conf sed -i "s,QL_BASE_URL,${ql_base_url},g" /etc/nginx/conf.d/front.conf - sed -i "s,QL_ROOT_OR_ALIAS,${root_or_alias},g" /etc/nginx/conf.d/front.conf ipv6=$(ip a | grep inet6) ipv6Str=""