fix: harden backend production deployment
This commit is contained in:
@@ -46,7 +46,8 @@ ZULIP_DEGRADED_MODE_ENABLED=true
|
|||||||
ZULIP_AUTO_RECONNECT_ENABLED=true
|
ZULIP_AUTO_RECONNECT_ENABLED=true
|
||||||
|
|
||||||
# Realtime and generated assets
|
# Realtime and generated assets
|
||||||
WEBSOCKET_PORT=3000
|
# The native WebSocket server listens separately from the REST API.
|
||||||
|
WEBSOCKET_PORT=3001
|
||||||
WEBSOCKET_NAMESPACE=/game
|
WEBSOCKET_NAMESPACE=/game
|
||||||
ACCOUNT_ASSET_DIR=generated/account-assets
|
ACCOUNT_ASSET_DIR=generated/account-assets
|
||||||
SKIN_GENERATION_OUTPUT_DIR=generated/skins
|
SKIN_GENERATION_OUTPUT_DIR=generated/skins
|
||||||
|
|||||||
21
deploy/nginx/whaletown-admin-v2.conf.example
Normal file
21
deploy/nginx/whaletown-admin-v2.conf.example
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name whaletownadmin.xinghangee.icu;
|
||||||
|
|
||||||
|
root /var/www/whale-town-end-v2/client/dist;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
location = /index.html {
|
||||||
|
add_header Cache-Control "no-cache";
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~* \.(?:js|css|png|jpg|jpeg|gif|svg|ico|woff2?)$ {
|
||||||
|
expires 7d;
|
||||||
|
add_header Cache-Control "public, max-age=604800, immutable";
|
||||||
|
try_files $uri =404;
|
||||||
|
}
|
||||||
|
}
|
||||||
28
deploy/nginx/whaletownend-v2.conf.example
Normal file
28
deploy/nginx/whaletownend-v2.conf.example
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name whaletownend.xinghangee.icu;
|
||||||
|
|
||||||
|
client_max_body_size 24m;
|
||||||
|
|
||||||
|
location /game {
|
||||||
|
proxy_pass http://127.0.0.1:3001/game;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_read_timeout 3600s;
|
||||||
|
proxy_send_timeout 3600s;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:3000;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ module.exports = {
|
|||||||
apps: [
|
apps: [
|
||||||
{
|
{
|
||||||
name: 'whale-town-end-v2',
|
name: 'whale-town-end-v2',
|
||||||
|
cwd: __dirname,
|
||||||
script: 'dist/main.js',
|
script: 'dist/main.js',
|
||||||
instances: 1,
|
instances: 1,
|
||||||
exec_mode: 'cluster',
|
exec_mode: 'cluster',
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { Injectable } from '@nestjs/common';
|
|||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { AppStatusResponseDto } from './business/shared';
|
import { AppStatusResponseDto } from './business/shared';
|
||||||
|
|
||||||
|
const packageJson: { version: string } = require('../package.json');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 应用服务类
|
* 应用服务类
|
||||||
*
|
*
|
||||||
@@ -31,7 +33,7 @@ export class AppService {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
service: 'Pixel Game Server',
|
service: 'Pixel Game Server',
|
||||||
version: '1.1.1',
|
version: packageJson.version,
|
||||||
status: 'running',
|
status: 'running',
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
uptime: Math.floor((Date.now() - this.startTime) / 1000),
|
uptime: Math.floor((Date.now() - this.startTime) / 1000),
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ export function validateZulipConfig(
|
|||||||
errors.push('API Key加密密钥长度必须至少32字符');
|
errors.push('API Key加密密钥长度必须至少32字符');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.server.botApiKey) {
|
if (!config.server.botApiKey && !config.errorHandling.degradedModeEnabled) {
|
||||||
errors.push('生产环境必须配置Zulip机器人API Key');
|
errors.push('生产环境必须配置Zulip机器人API Key');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user