添加云虚拟主机文件部署,增加game-docker的安全加固
This commit is contained in:
@@ -10,6 +10,14 @@ upstream wxserver_service {
|
||||
server wxserver:3000;
|
||||
}
|
||||
|
||||
# ── 限速区域定义(在 http 块级别,此处用 geo 标记 + limit_req_zone)──
|
||||
# 登录接口:每个 IP 每秒最多 5 次请求,突发缓冲 10 次
|
||||
limit_req_zone $binary_remote_addr zone=login_limit:10m rate=5r/s;
|
||||
# 通用 API:每个 IP 每秒最多 30 次请求
|
||||
limit_req_zone $binary_remote_addr zone=api_limit:10m rate=30r/s;
|
||||
# 连接数限制:每个 IP 同时最多 20 个连接
|
||||
limit_conn_zone $binary_remote_addr zone=conn_limit:10m;
|
||||
|
||||
# =============================================
|
||||
# 域名路由模式 + SSL(Let's Encrypt 自动证书)
|
||||
#
|
||||
@@ -108,10 +116,45 @@ server {
|
||||
ssl_certificate_key /etc/letsencrypt/live/${API_DOMAIN}/privkey.pem;
|
||||
include /etc/nginx/snippets/ssl-params.conf;
|
||||
|
||||
# 隐藏服务器版本信息
|
||||
server_tokens off;
|
||||
|
||||
# 请求体大小限制(防止大请求攻击)
|
||||
client_max_body_size 10m;
|
||||
client_body_timeout 30s;
|
||||
client_header_timeout 30s;
|
||||
|
||||
# 连接数限制
|
||||
limit_conn conn_limit 20;
|
||||
|
||||
# ── 屏蔽敏感文件(直接返回 404,不暴露文件存在)──
|
||||
location ~* \.(env|sh|bak|sql|log|git|svn|htaccess|htpasswd|ini|conf)$ {
|
||||
return 404;
|
||||
}
|
||||
location ~* /(ntunnel_mysql|phpMyAdmin|phpmyadmin|adminer|debug)\.php$ {
|
||||
return 404;
|
||||
}
|
||||
location ~ /\. {
|
||||
return 404;
|
||||
}
|
||||
|
||||
# ── 登录接口限速(防爆破)──
|
||||
location ~* /source/login/ {
|
||||
limit_req zone=login_limit burst=10 nodelay;
|
||||
limit_req_status 429;
|
||||
proxy_pass http://api_service;
|
||||
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_set_header X-Forwarded-Port $server_port;
|
||||
}
|
||||
|
||||
# wxserver 路由:/wx/ 前缀转发给 wxserver 容器,自动去除 /wx 前缀
|
||||
# 例:/wx/auth/oa/callback → wxserver:/auth/oa/callback
|
||||
# 例:/wx/api/login → wxserver:/api/login
|
||||
location /wx/ {
|
||||
limit_req zone=api_limit burst=50 nodelay;
|
||||
proxy_pass http://wxserver_service/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
@@ -132,6 +175,7 @@ server {
|
||||
|
||||
# PHP API(所有其他请求)
|
||||
location / {
|
||||
limit_req zone=api_limit burst=50 nodelay;
|
||||
proxy_pass http://api_service;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
@@ -151,7 +195,30 @@ server {
|
||||
ssl_certificate_key /etc/letsencrypt/live/${DLWEB_DOMAIN}/privkey.pem;
|
||||
include /etc/nginx/snippets/ssl-params.conf;
|
||||
|
||||
# 隐藏服务器版本信息
|
||||
server_tokens off;
|
||||
|
||||
# 请求体大小限制
|
||||
client_max_body_size 10m;
|
||||
client_body_timeout 30s;
|
||||
client_header_timeout 30s;
|
||||
|
||||
# 连接数限制
|
||||
limit_conn conn_limit 20;
|
||||
|
||||
# ── 屏蔽敏感文件 ──
|
||||
location ~* \.(env|sh|bak|sql|log|git|svn|htaccess|htpasswd|ini|conf)$ {
|
||||
return 404;
|
||||
}
|
||||
location ~* /(ntunnel_mysql|phpMyAdmin|phpmyadmin|adminer|debug)\.php$ {
|
||||
return 404;
|
||||
}
|
||||
location ~ /\. {
|
||||
return 404;
|
||||
}
|
||||
|
||||
location / {
|
||||
limit_req zone=api_limit burst=50 nodelay;
|
||||
proxy_pass http://dlweb_service;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
|
||||
Reference in New Issue
Block a user