From f9e471aa37316af5fac5fd0aaed352cc2c35716f Mon Sep 17 00:00:00 2001 From: yuejiajun <1530620364@qq.com> Date: Wed, 20 Aug 2025 16:00:41 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=9F=BA=E6=9C=AC=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E3=80=91nginx=20home?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/Resources/nginx/conf/conf-default.rar | Bin 1230 -> 0 bytes base/Resources/nginx/conf/conf-home.rar | Bin 2926 -> 0 bytes base/Resources/nginx/conf/home-windows.conf | 44 ++- base/Resources/nginx/html/404.html | 196 +++++++++++ base/Resources/nginx/html/50x.html | 354 ++++++++++++++++++++ base/Resources/quick.bat | 142 +++++++- base/install_all.iss | 2 +- 7 files changed, 719 insertions(+), 19 deletions(-) delete mode 100644 base/Resources/nginx/conf/conf-default.rar delete mode 100644 base/Resources/nginx/conf/conf-home.rar create mode 100644 base/Resources/nginx/html/404.html create mode 100644 base/Resources/nginx/html/50x.html diff --git a/base/Resources/nginx/conf/conf-default.rar b/base/Resources/nginx/conf/conf-default.rar deleted file mode 100644 index e90f05c24a23655996669a80f919c1a08818b282..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1230 zcmV;<1Tp(kVR9iF2LS+er-S$*1ONa54?iij^AHo1>gp|`B>fZ{BT5b_W^$7Lfu&h- zcjHP(xtX_fsXC|EdE{9Cw(Bj8N3oxY@^=wPj-#9Kw(Mv3B_u42@{!)j42K6wwx0m!+hE z17gE`UF!pV_BsjM(qg{O9sZ->b6xeZ=F2pc==S|Bzk0vFDnQaMNa>hbyI!w;I5zea1x~ z(W!YReN%un3^t!M2q9a{IC=pm_cv~8+>AjYlFeQ5U0BlPLQ2zmZWrM(lR(CaMA3qA zhqQD<%KJTCJ7lZ(fwqEU-zD(Jn|Wnc;-1C>`s`N$=ps91pjkeEkAr_%YWw&HK$LrC z5?5ui25YhQe=Fxa4H``#=;7)tcGUb)&}37_*2<6BB&AKIV>-$PPeMBBooAZ4$DOIT z5gmV8$4whop=orn4JDbgZeFXfZ$~nW#jlzyWkk5GvSECzgiEPIE_&FeUeYbaN)aI1 zpXF8r`Kh7^#9~OS^%3V~0#E*S{GjoaU*PlCh#mC(aT=Hv;uw7#9E-&vo9*DTROK++ z@Bw_f`!t+@teg^@hAUF?;0Noy0ZRtK+B6#wqPD+M8uXIKZ>7jwoA7hn?EcC4+sM*h zgG^o$(RQW7oAFYF<9W(A`(fXy-XJ>mE)ML%5j-0Xy?Fs%BejYBorV3)ptWK)7fgBV zC5C+*{x~;Q4YA!#XF)MWkFxwsMQg+V*$K=X7WtyXi3tl|aS@Q6Nz*$BT6sU>LMAi!8R^a6&y9T+Z*@1&nbN(Hiw}-EiHL$?(VXAW&w<*hiTbnB}L*? zIj3l*bbZA$~N5^wB;AG;oe;?fe+{Lgp>+!H%el zz%U4)-r7u=7!6LHC6^^Aa~UNTsbI=eW>5rd^uW%Oq~{kR$BFqT)O+Zz-d^9kmcabL z@o+0;^KYtJXrR=w>?wWw`$?P*F1cv@uwG=5 s!Zc8wc7Hh_!IG;!mfkhp8rCEU)xvY|T^r%1up2wEo-Dz%Td0XV2+b>J0{{R3 diff --git a/base/Resources/nginx/conf/conf-home.rar b/base/Resources/nginx/conf/conf-home.rar deleted file mode 100644 index 9df782dded9105169ae2d031a3946249c782c62c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2926 zcmV-!3z76vVR9iF2LS*rdR;yt1ONa55A#hF5&wA{+r`Nos|G$_cEZcf-x!}rux+G4 zgHAG9>4%ezAQZuxtrJfLDf1En*i6&Up{t$FkyWCv1AgxpHH`kg#l0KMaPehY-_$Nr zk4yDE_Aq%5$XaxX{_s3^Ki2X+vhN5U!QX7lz9wJ`ZBiuQQ7OYooiUC*;yCqhYsDqr zGHcLGP9utNjifj_q%7($4vl7nWRFeKGhNT`$dgvt%SOsC7XF-%;nR=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ru%~8M!j|RNzM4cV8b-$2%w4 z+6T*^Xde9xV3rk4ge6vT<{r8ob-ELSNx=Aaim}Z&uNZUg(U9PmTo-)vOfh(di!sc& zh~x0MCkqq4bGM_oMKTH#y7E3N?t;J{OHSERBU{X0$`C3TY3Ye@f0Jok4%<3HtQfi&&qeaCsx)J z(BjR3 z@yCc&EIgm0P>F;{yn5SDI;}Dv!tF7uDG-Vs+u7Uc2ow7JH@!7$aUTQ_xWcahS$Kc2 zJ8I)FGgsL~)M$e4IeDD*SjfE|4L9zJLr{9TTGHBChuxlO_G(!8ue`G2<933_Ln+a diff --git a/base/Resources/nginx/conf/home-windows.conf b/base/Resources/nginx/conf/home-windows.conf index 563301c..684cb6e 100644 --- a/base/Resources/nginx/conf/home-windows.conf +++ b/base/Resources/nginx/conf/home-windows.conf @@ -7,6 +7,15 @@ server { listen 18080; server_name _; + root html; + + error_page 404 /404.html; + + error_page 500 /50x.html?error=500; + error_page 502 /50x.html?error=502; + error_page 503 /50x.html?error=503; + error_page 504 /50x.html?error=504; + gzip on; gzip_min_length 1k; gzip_comp_level 9; @@ -14,19 +23,26 @@ server { gzip_vary on; gzip_disable "MSIE [1-6]\."; - proxy_set_header Host $host; + # 传递用户请求的原始Host(域名或IP+端口) + # proxy_set_header Host $host; + proxy_set_header Host $http_host; + # 传递用户真实IP proxy_set_header X-Real-IP $remote_addr; + # 传递真实IP,包含整个代理链路的IP信息 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + # 传递用户请求的原始协议 (http 或 https) proxy_set_header X-Forwarded-Proto $scheme; + # 用户原始的Cookie等完整请求头 + proxy_set_header Cookie $http_cookie; add_header X-Content-Type-Options "nosniff"; add_header X-Frame-Options "SAMEORIGIN"; proxy_http_version 1.1; proxy_set_header Connection ""; - proxy_read_timeout 60s; + proxy_read_timeout 10s; proxy_connect_timeout 5s; - proxy_send_timeout 30s; + proxy_send_timeout 10s; proxy_buffering off; @@ -34,28 +50,40 @@ server { rewrite ^ /home permanent; } + location = /404.html { + root html; + internal; + } + + location = /50x.html { + root /usr/share/nginx/html; + internal; + + proxy_set_header X-Original-URI $request_uri; + proxy_set_header X-Real-IP $remote_addr; + } + location / { proxy_pass http://portal/; + proxy_intercept_errors on; } location /assets/ { proxy_pass http://portal/assets/; expires 30d; access_log off; + proxy_intercept_errors on; } location /api/ { proxy_pass http://portal/api/; client_max_body_size 100M; + proxy_intercept_errors on; } location /dev-api/ { proxy_pass http://portal/dev-api/; client_max_body_size 100M; - } - - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /usr/share/nginx/html; + proxy_intercept_errors on; } } \ No newline at end of file diff --git a/base/Resources/nginx/html/404.html b/base/Resources/nginx/html/404.html new file mode 100644 index 0000000..23a63f3 --- /dev/null +++ b/base/Resources/nginx/html/404.html @@ -0,0 +1,196 @@ + + + + + + 页面未找到 - 404错误 + + + +
+

404

+

哎呀!页面找不到啦

+

您访问的页面可能已被移除、更名或暂时不可用。请检查URL是否正确,或使用搜索功能查找您需要的内容。

+ + + + + +
Nginx
+
+ + + + \ No newline at end of file diff --git a/base/Resources/nginx/html/50x.html b/base/Resources/nginx/html/50x.html new file mode 100644 index 0000000..17cd47c --- /dev/null +++ b/base/Resources/nginx/html/50x.html @@ -0,0 +1,354 @@ + + + + + + 服务器错误 - <span id="error-code">500</span> + + + + +
+

500

+

服务器内部错误

+ +
+ 服务器遇到了意外的条件,无法完成您的请求。 +
+ +

+ 我们的技术团队已收到通知,正在努力解决问题。
+ 请稍后再试或联系技术支持获取帮助。 +

+ +
+
+ + 服务器状态监控 +
+
+ Web服务器 + 运行正常 +
+
+ 应用程序服务 + 遇到问题 +
+
+ 数据库连接 + 连接正常 +
+
+ 错误发生时间 + +
+
+ + + +
+

页面将在 15 秒后自动重新加载

+
+ +
+

技术信息:

+

错误代码: 500

+

请求ID: REQ-${Math.random().toString(36).substr(2, 9).toUpperCase()}

+

服务器: ${window.location.hostname}

+
+ +
+ Powered by Nginx +
+
+ + + + \ No newline at end of file diff --git a/base/Resources/quick.bat b/base/Resources/quick.bat index 05eed38..6ef69c3 100644 --- a/base/Resources/quick.bat +++ b/base/Resources/quick.bat @@ -8,27 +8,40 @@ call :log_info SCRIPT_DIR=%SCRIPT_DIR% cd /d "%SCRIPT_DIR%" -call :Start "Redis" "%SCRIPT_DIR%redis" "redis-server.exe" "redis.conf" - -call :Start "MinIO" "%SCRIPT_DIR%io" "minio-server.bat" - -call :Start "RocketMQ" "%SCRIPT_DIR%rocketmq\sbin" "rocketmq.bat" - +call :main pause && exit /b 0 :log_info call :GetFormattedTime -echo [%FormattedTime%] - [INFO] - %* +if defined LOG_TITLE ( + echo. + echo [%FormattedTime%] - [INFO] - ==================== %LOG_TITLE% ==================== + set "LOG_TITLE=" +) else ( + echo [%FormattedTime%] - [INFO] - %* +) exit /b 0 :log_warn call :GetFormattedTime -echo [%FormattedTime%] - [WARN] - %* +if defined LOG_TITLE ( + echo. + echo [%FormattedTime%] - [WARN] - ==================== %LOG_TITLE% ==================== + set "LOG_TITLE=" +) else ( + echo [%FormattedTime%] - [WARN] - %* +) exit /b 0 :log_error call :GetFormattedTime -echo [%FormattedTime%] - [ERROR] - %* +if defined LOG_TITLE ( + echo. + echo [%FormattedTime%] - [ERROR] - ==================== %LOG_TITLE% ==================== + set "LOG_TITLE=" +) else ( + echo [%FormattedTime%] - [ERROR] - %* +) exit /b 0 :rar @@ -56,6 +69,17 @@ call :log_info Password: Password#!CURRENT_DATE! exit /b 0 +:GetSinglePidByPort +setlocal +call :RandomStr single_pid_tmp +call :log_info netstat -ano ^| grep -E ":%1 " ^| grep "LISTENING" ^| awk "{print $NF}" ^| head -n 1 +netstat -ano | grep -E ":%1 " | grep "LISTENING" | awk "{print $NF}" | head -n 1 > %single_pid_tmp%.txt +set /p pid=<%single_pid_tmp%.txt +call :log_info pid: %pid% +del %single_pid_tmp%.txt +endlocal & set pid=%pid% +exit /b 0 + :RandomStr setlocal set "len=%~1" @@ -113,4 +137,102 @@ exit /b 0 :GetDate for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "datetime=%%a" set "FormattedDate=%datetime:~0,4%%datetime:~4,2%%datetime:~6,2%" -exit /b 0 \ No newline at end of file +exit /b 0 + +:GetUsageNumberOfPidsByPort +setlocal +set "PORT=%~1" +set /a "UNIQUE_COUNT=0" + +if "!PORT!"=="" ( + call :log_error ERROR: Port number required + endlocal & exit /b 0 +) + +set "TEMP_FILE=%TEMP%\port_%PORT%_%RANDOM%_%TIME::=_%.tmp" +set "PID_LIST_FILE=%TEMP%\pids_%PORT%_%RANDOM%.tmp" + +call :log_info Checking for processes using port !PORT!... +netstat -ano | grep -E ":!PORT! " > "!TEMP_FILE!" + +if !errorlevel! neq 0 ( + call :log_info No process found using port !PORT! + del "!TEMP_FILE!" 2>nul + endlocal & exit /b 0 +) + +echo. > "!PID_LIST_FILE!" + +echo. +set "LOG_TITLE=Processes using port !PORT!" +call :log_info ignore +for /f "tokens=5" %%a in (!TEMP_FILE!) do ( + set "PID=%%a" + :: grep -E "^^!PID! $" "!PID_LIST_FILE!" >nul + findstr /x "!PID!" "!PID_LIST_FILE!" >nul + if !errorlevel! neq 0 ( + echo !PID! >> "!PID_LIST_FILE!" + set /a "UNIQUE_COUNT+=1" + call :log_info [!UNIQUE_COUNT!] PID: !PID! + set "PROCESS_NAME=" + set "SESSION_NAME=" + set "SESSION_NUM=" + set "MEM_USAGE=" + + for /f "tokens=1,2,3,4,5*" %%b in ('tasklist /fi "PID eq !PID!" /fo table ^| findstr /i "!PID!"') do ( + if not "%%b"=="=" if not "%%b"=="Image" ( + call :log_info "PROCESS_NAME=%%b" + call :log_info "PID_VALUE=%%c" + call :log_info "SESSION_NAME=%%d" + call :log_info "SESSION_NUM=%%e" + call :log_info "MEM_USAGE=%%f" + ) + ) + + if not "!PROCESS_NAME!"=="" ( + call :log_info Process: !PROCESS_NAME! + call :log_info Memory: !MEM_USAGE! + ) + echo. + ) +) + +if !UNIQUE_COUNT! gtr 0 ( + set "LOG_TITLE=PIDs using port !PORT!" + call :log_info ignore + :: type "!PID_LIST_FILE!" + call :log_info Total: !UNIQUE_COUNT! process +) + +del "!TEMP_FILE!" 2>nul +del "!PID_LIST_FILE!" 2>nul + +endlocal & exit /b %UNIQUE_COUNT% + +:main +setlocal + +call :GetUsageNumberOfPidsByPort 18080 +if !ERRORLEVEL! neq 0 ( + call :log_info Found !ERRORLEVEL! processes. + call :GetSinglePidByPort 18080 + set "LOG_TITLE=Killing Process !pid!" + call :log_info ignore + :: taskkill -f -pid !pid! >nul + taskkill -f -im home-web.exe +) + +timeout /t 1 /nobreak >nul +call :Start "Nginx" "%SCRIPT_DIR%nginx" "home-web.exe" "-c" "conf/web.conf" + +timeout /t 3 /nobreak >nul +call :Start "Redis" "%SCRIPT_DIR%redis" "redis-server.exe" "redis.conf" + +timeout /t 3 /nobreak >nul +call :Start "MinIO" "%SCRIPT_DIR%io" "minio-server.bat" + +timeout /t 3 /nobreak >nul +call :Start "RocketMQ" "%SCRIPT_DIR%rocketmq\sbin" "rocketmq.bat" + +endlocal +cmd /k \ No newline at end of file diff --git a/base/install_all.iss b/base/install_all.iss index 847b3e2..ac1ca31 100644 --- a/base/install_all.iss +++ b/base/install_all.iss @@ -1,7 +1,7 @@ ;iss #define MyAppName "基础环境" -#define MyAppVersion "1.0.6" +#define MyAppVersion "1.0.7" #define MyAppPublisher "X" #define MyAppURL "~" #define MyAppExeName "command"