diff --git a/base/Resources/nginx/conf/conf-default.rar b/base/Resources/nginx/conf/conf-default.rar
deleted file mode 100644
index e90f05c..0000000
Binary files a/base/Resources/nginx/conf/conf-default.rar and /dev/null differ
diff --git a/base/Resources/nginx/conf/conf-home.rar b/base/Resources/nginx/conf/conf-home.rar
deleted file mode 100644
index 9df782d..0000000
Binary files a/base/Resources/nginx/conf/conf-home.rar and /dev/null differ
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 @@
+
+
+
+
+
+ 服务器错误 - 500
+
+
+
+
+
+
500
+
服务器内部错误
+
+
+ 服务器遇到了意外的条件,无法完成您的请求。
+
+
+
+ 我们的技术团队已收到通知,正在努力解决问题。
+ 请稍后再试或联系技术支持获取帮助。
+
+
+
+
+
+ 服务器状态监控
+
+
+ Web服务器
+ 运行正常
+
+
+ 应用程序服务
+ 遇到问题
+
+
+ 数据库连接
+ 连接正常
+
+
+ 错误发生时间
+
+
+
+
+
+
+
+
+
+
技术信息:
+
错误代码: 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"