fix: 使用 root 用户启动 Nginx,后端应用以 appuser 运行

- Nginx 以 root 用户运行(解决 80 端口绑定权限问题)
- 后端应用以 appuser 用户运行(保持安全性)
- 移除 setcap 相关配置(不再需要)
- 更新目录权限设置(Nginx 相关目录使用 root,应用目录使用 appuser)
This commit is contained in:
WrBug
2025-12-03 05:34:26 +08:00
parent 5451dd87e5
commit f33f03a4a8
3 changed files with 15 additions and 16 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
user appuser;
user root;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
+2 -2
View File
@@ -17,9 +17,9 @@ cleanup() {
# 注册信号处理
trap cleanup SIGTERM SIGINT
# 启动后端服务(后台运行)
# 启动后端服务(以 appuser 用户运行,后台运行)
echo "启动后端服务..."
java -jar /app/app.jar --spring.profiles.active=${SPRING_PROFILES_ACTIVE:-prod} &
su appuser -c "cd /app && java -jar /app/app.jar --spring.profiles.active=${SPRING_PROFILES_ACTIVE:-prod}" &
BACKEND_PID=$!
# 等待后端服务启动