diff --git a/plugins/openresty/conf/nginx.conf b/plugins/openresty/conf/nginx.conf index d0b66ff63..07cd73d9a 100644 --- a/plugins/openresty/conf/nginx.conf +++ b/plugins/openresty/conf/nginx.conf @@ -64,6 +64,14 @@ http gzip_proxied expired no-cache no-store private auth; gzip_disable "MSIE [1-6]\."; + brotli on; + brotli_min_length 256; + brotli_buffers 32 8k; + brotli_comp_level 6; + brotli_window 16m; + brotli_static on; + brotli_types text/plain text/css text/xml text/javascript text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml application/atom+xml application/vnd.ms-fontobject application/x-font-ttf application/x-font-opentype application/x-font-truetype font/tpl font/opentype font/otf font/ttf image/svg+xml image/x-icon image/vnd.microsoft.icon application/wasm application/manifest+json; + limit_conn_zone $binary_remote_addr zone=perip:10m; limit_conn_zone $server_name zone=perserver:10m; diff --git a/plugins/openresty/install.sh b/plugins/openresty/install.sh index 66ac75122..9aa98a06c 100755 --- a/plugins/openresty/install.sh +++ b/plugins/openresty/install.sh @@ -4,6 +4,9 @@ export PATH # cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/openresty && bash install.sh install 1.21.4 # cd /www/server/mdserver-web/plugins/openresty && bash install.sh install 1.21.4 +# cd /www/server/mdserver-web/plugins/openresty && bash install.sh install 1.29.2 + +# curl -I -H "Accept-Encoding: br" http://localhost # cd /www/server/mdserver-web && python3 plugins/openresty/index.py run_info diff --git a/plugins/openresty/versions/1.17.8/install.sh b/plugins/openresty/versions/1.17.8/install.sh index 544c97b9f..ee8d30fd0 100644 --- a/plugins/openresty/versions/1.17.8/install.sh +++ b/plugins/openresty/versions/1.17.8/install.sh @@ -102,6 +102,15 @@ Install_openresty() # OPENSSL_LIB_DEPEND_DIR=`brew info openssl@1.1 | grep ${BREW_DIR}/Cellar/openssl@1.1 | cut -d \ -f 1 | awk 'END {print}'` # OPTIONS="${OPTIONS} --with-openssl=${OPENSSL_LIB_DEPEND_DIR}" else + if [ ! -f ${openrestyDir}/pcre-${pcreVersion}.tar.gz ];then + wget --no-check-certificate -O ${openrestyDir}/pcre-${pcreVersion}.tar.gz https://netix.dl.sourceforge.net/project/pcre/pcre/${pcreVersion}/pcre-${pcreVersion}.tar.gz + fi + + if [ ! -d ${openrestyDir}/pcre-${pcreVersion} ];then + cd ${openrestyDir} && tar -zxvf pcre-${pcreVersion}.tar.gz + fi + OPTIONS="${OPTIONS} --with-pcre=${openrestyDir}/pcre-${pcreVersion}" + echo "openssl" # if [ ! -f ${openrestyDir}/openssl-${opensslVersion}.tar.gz ];then # wget --no-check-certificate -O ${openrestyDir}/openssl-${opensslVersion}.tar.gz https://www.openssl.org/source/openssl-${opensslVersion}.tar.gz @@ -113,6 +122,14 @@ Install_openresty() # OPTIONS="${OPTIONS} --with-openssl=${openrestyDir}/openssl-${opensslVersion}" fi + # br + if [ ! -d ${openrestyDir}/openresty-${VERSION}/ngx_brotli ];then + cd ${openrestyDir}/openresty-${VERSION} && git clone https://github.com/wxx9248/ngx_brotli.git + cd ${openrestyDir}/openresty-${VERSION}/ngx_brotli && git submodule update --init + + OPTIONS="${OPTIONS} --add-module=./ngx_brotli" + fi + # --with-openssl=$serverPath/source/lib/openssl-1.0.2q cd ${openrestyDir}/openresty-${VERSION} && ./configure \ diff --git a/plugins/openresty/versions/1.19.3/install.sh b/plugins/openresty/versions/1.19.3/install.sh index 2af69a9b1..5b34d13b3 100644 --- a/plugins/openresty/versions/1.19.3/install.sh +++ b/plugins/openresty/versions/1.19.3/install.sh @@ -103,6 +103,15 @@ Install_openresty() # OPENSSL_LIB_DEPEND_DIR=`brew info openssl@1.1 | grep ${BREW_DIR}/Cellar/openssl@1.1 | cut -d \ -f 1 | awk 'END {print}'` # OPTIONS="${OPTIONS} --with-openssl=${OPENSSL_LIB_DEPEND_DIR}" else + if [ ! -f ${openrestyDir}/pcre-${pcreVersion}.tar.gz ];then + wget --no-check-certificate -O ${openrestyDir}/pcre-${pcreVersion}.tar.gz https://netix.dl.sourceforge.net/project/pcre/pcre/${pcreVersion}/pcre-${pcreVersion}.tar.gz + fi + + if [ ! -d ${openrestyDir}/pcre-${pcreVersion} ];then + cd ${openrestyDir} && tar -zxvf pcre-${pcreVersion}.tar.gz + fi + OPTIONS="${OPTIONS} --with-pcre=${openrestyDir}/pcre-${pcreVersion}" + echo "openssl" # if [ ! -f ${openrestyDir}/openssl-${opensslVersion}.tar.gz ];then # wget --no-check-certificate -O ${openrestyDir}/openssl-${opensslVersion}.tar.gz https://www.openssl.org/source/openssl-${opensslVersion}.tar.gz @@ -114,6 +123,14 @@ Install_openresty() # OPTIONS="${OPTIONS} --with-openssl=${openrestyDir}/openssl-${opensslVersion}" fi + # br + if [ ! -d ${openrestyDir}/openresty-${VERSION}/ngx_brotli ];then + cd ${openrestyDir}/openresty-${VERSION} && git clone https://github.com/wxx9248/ngx_brotli.git + cd ${openrestyDir}/openresty-${VERSION}/ngx_brotli && git submodule update --init + + OPTIONS="${OPTIONS} --add-module=./ngx_brotli" + fi + # --with-openssl=$serverPath/source/lib/openssl-1.0.2q cd ${openrestyDir}/openresty-${VERSION} && ./configure \ diff --git a/plugins/openresty/versions/1.21.4/install.sh b/plugins/openresty/versions/1.21.4/install.sh index 0ceaa3a91..dcd36f627 100644 --- a/plugins/openresty/versions/1.21.4/install.sh +++ b/plugins/openresty/versions/1.21.4/install.sh @@ -103,6 +103,15 @@ Install_openresty() # OPENSSL_LIB_DEPEND_DIR=`brew info openssl@1.1 | grep ${BREW_DIR}/Cellar/openssl@1.1 | cut -d \ -f 1 | awk 'END {print}'` # OPTIONS="${OPTIONS} --with-openssl=${OPENSSL_LIB_DEPEND_DIR}" else + if [ ! -f ${openrestyDir}/pcre-${pcreVersion}.tar.gz ];then + wget --no-check-certificate -O ${openrestyDir}/pcre-${pcreVersion}.tar.gz https://netix.dl.sourceforge.net/project/pcre/pcre/${pcreVersion}/pcre-${pcreVersion}.tar.gz + fi + + if [ ! -d ${openrestyDir}/pcre-${pcreVersion} ];then + cd ${openrestyDir} && tar -zxvf pcre-${pcreVersion}.tar.gz + fi + OPTIONS="${OPTIONS} --with-pcre=${openrestyDir}/pcre-${pcreVersion}" + if [ ! -f ${openrestyDir}/openssl-${opensslVersion}.tar.gz ];then wget --no-check-certificate -O ${openrestyDir}/openssl-${opensslVersion}.tar.gz https://www.openssl.org/source/openssl-${opensslVersion}.tar.gz fi @@ -113,6 +122,13 @@ Install_openresty() OPTIONS="${OPTIONS} --with-openssl=${openrestyDir}/openssl-${opensslVersion}" fi + # br + if [ ! -d ${openrestyDir}/openresty-${VERSION}/ngx_brotli ];then + cd ${openrestyDir}/openresty-${VERSION} && git clone https://github.com/wxx9248/ngx_brotli.git + cd ${openrestyDir}/openresty-${VERSION}/ngx_brotli && git submodule update --init + + OPTIONS="${OPTIONS} --add-module=./ngx_brotli" + fi # --with-openssl=$serverPath/source/lib/openssl-1.0.2q cd ${openrestyDir}/openresty-${VERSION} && ./configure \ diff --git a/plugins/openresty/versions/1.25.3/install.sh b/plugins/openresty/versions/1.25.3/install.sh index 0becee2f0..32ac58f80 100644 --- a/plugins/openresty/versions/1.25.3/install.sh +++ b/plugins/openresty/versions/1.25.3/install.sh @@ -103,6 +103,15 @@ Install_openresty() # OPENSSL_LIB_DEPEND_DIR=`brew info openssl@1.1 | grep ${BREW_DIR}/Cellar/openssl@1.1 | cut -d \ -f 1 | awk 'END {print}'` # OPTIONS="${OPTIONS} --with-openssl=${OPENSSL_LIB_DEPEND_DIR}" else + if [ ! -f ${openrestyDir}/pcre-${pcreVersion}.tar.gz ];then + wget --no-check-certificate -O ${openrestyDir}/pcre-${pcreVersion}.tar.gz https://netix.dl.sourceforge.net/project/pcre/pcre/${pcreVersion}/pcre-${pcreVersion}.tar.gz + fi + + if [ ! -d ${openrestyDir}/pcre-${pcreVersion} ];then + cd ${openrestyDir} && tar -zxvf pcre-${pcreVersion}.tar.gz + fi + OPTIONS="${OPTIONS} --with-pcre=${openrestyDir}/pcre-${pcreVersion}" + if [ ! -f ${openrestyDir}/openssl-${opensslVersion}.tar.gz ];then wget --no-check-certificate -O ${openrestyDir}/openssl-${opensslVersion}.tar.gz https://www.openssl.org/source/openssl-${opensslVersion}.tar.gz fi @@ -129,6 +138,13 @@ Install_openresty() OPTIONS="${OPTIONS} --with-cc-opt=-I${openrestyDir}/libressl-${libresslVersion}/libressl/build/lib" fi + # br + if [ ! -d ${openrestyDir}/openresty-${VERSION}/ngx_brotli ];then + cd ${openrestyDir}/openresty-${VERSION} && git clone https://github.com/wxx9248/ngx_brotli.git + cd ${openrestyDir}/openresty-${VERSION}/ngx_brotli && git submodule update --init + + OPTIONS="${OPTIONS} --add-module=./ngx_brotli" + fi cd ${openrestyDir}/openresty-${VERSION} && ./configure \ --prefix=$serverPath/openresty \ diff --git a/plugins/openresty/versions/1.27.1/install.sh b/plugins/openresty/versions/1.27.1/install.sh index 42704f27c..9208776d7 100644 --- a/plugins/openresty/versions/1.27.1/install.sh +++ b/plugins/openresty/versions/1.27.1/install.sh @@ -129,6 +129,13 @@ Install_openresty() OPTIONS="${OPTIONS} --with-cc-opt=-I${openrestyDir}/libressl-${libresslVersion}/libressl/build/lib" fi + # br + if [ ! -d ${openrestyDir}/openresty-${VERSION}/ngx_brotli ];then + cd ${openrestyDir}/openresty-${VERSION} && git clone https://github.com/wxx9248/ngx_brotli.git + cd ${openrestyDir}/openresty-${VERSION}/ngx_brotli && git submodule update --init + + OPTIONS="${OPTIONS} --add-module=./ngx_brotli" + fi cd ${openrestyDir}/openresty-${VERSION} && ./configure \ --prefix=$serverPath/openresty \ diff --git a/plugins/openresty/versions/1.29.2/install.sh b/plugins/openresty/versions/1.29.2/install.sh index 72b10158b..e1b2dc987 100644 --- a/plugins/openresty/versions/1.29.2/install.sh +++ b/plugins/openresty/versions/1.29.2/install.sh @@ -14,7 +14,7 @@ sysName=`uname` action=$1 type=$2 -VERSION=1.29.2.1 +VERSION=1.29.2.3 openrestyDir=${serverPath}/source/openresty @@ -72,9 +72,9 @@ Install_openresty() OPTIONS='' - opensslVersion="1.1.1p" + opensslVersion="3.4.4" libresslVersion="3.9.1" - pcreVersion='8.38' + pcreVersion='8.45' if [ "$sysName" == "Darwin" ];then if [ ! -f ${openrestyDir}/pcre-${pcreVersion}.tar.gz ];then @@ -114,7 +114,7 @@ Install_openresty() fi - if [[ "$VERSION" =~ "1.25.3" ]] || [[ "$VERSION" =~ "1.27.1" ]];then + if [[ "$VERSION" =~ "1.29.2" ]];then OPTIONS="${OPTIONS} --with-http_v3_module" if [ ! -f ${openrestyDir}/libressl-${libresslVersion}.tar.gz ];then @@ -129,6 +129,14 @@ Install_openresty() OPTIONS="${OPTIONS} --with-cc-opt=-I${openrestyDir}/libressl-${libresslVersion}/libressl/build/lib" fi + # br + if [ ! -d ${openrestyDir}/openresty-${VERSION}/ngx_brotli ];then + cd ${openrestyDir}/openresty-${VERSION} && git clone https://github.com/wxx9248/ngx_brotli.git + cd ${openrestyDir}/openresty-${VERSION}/ngx_brotli && git submodule update --init + + OPTIONS="${OPTIONS} --add-module=./ngx_brotli" + fi + cd ${openrestyDir}/openresty-${VERSION} && ./configure \ --prefix=$serverPath/openresty \ @@ -167,6 +175,10 @@ Install_openresty() if [ -d $openrestyDir/openresty-${VERSION} ];then rm -rf $openrestyDir/openresty-${VERSION} fi + + # if [ -d $openrestyDir/ngx_brotli ];then + # rm -rf $openrestyDir/ngx_brotli + # fi echo 'Installation of Openresty completed' } diff --git a/web/core/mw.py b/web/core/mw.py index b68830a1e..208d049b2 100644 --- a/web/core/mw.py +++ b/web/core/mw.py @@ -399,12 +399,36 @@ def systemdCfgDir(): return "/tmp" -def formatDate(format="%Y-%m-%d %H:%M:%S", times=None): +def formatDate(fmat="%Y-%m-%d %H:%M:%S", times=None, time_zone=None): # 格式化指定时间戳 if not times: times = int(time.time()) - time_local = time.localtime(times) - return time.strftime(format, time_local) + + # if time_zone is None: + # try: + # import tzlocal + # time_zone = str(tzlocal.get_localzone()) + # except: + # try: + # time_zone = time.tzname[0] + # except: + # time_zone = None + + if time_zone: + old_tz = os.environ.get('TZ') + os.environ['TZ'] = time_zone + time.tzset() + time_local = time.localtime(times) + result = time.strftime(fmat, time_local) + if old_tz: + os.environ['TZ'] = old_tz + else: + del os.environ['TZ'] + time.tzset() + return result + else: + time_local = time.localtime(times) + return time.strftime(fmat, time_local) def strfToTime(sdate):