新增白名單

This commit is contained in:
2025-08-01 13:34:19 +08:00
parent a54ae31896
commit 6434710957
3 changed files with 131 additions and 7 deletions

View File

@@ -18,6 +18,9 @@
- 219.87.170.253
- 125.228.50.228
### 新增IP
- 218.161.107.138
## 完整IP清單一行一個
114.33.18.13
125.229.65.83
@@ -26,6 +29,7 @@
211.72.69.222
219.87.170.253
125.228.50.228
218.161.107.138
## 防火牆規則格式
@@ -39,7 +43,8 @@ $allowedIPs = @(
"220.132.236.89",
"211.72.69.222",
"219.87.170.253",
"125.228.50.228"
"125.228.50.228",
"218.161.107.138"
)
foreach ($ip in $allowedIPs) {
@@ -57,6 +62,7 @@ iptables -A INPUT -s 220.132.236.89 -j ACCEPT
iptables -A INPUT -s 211.72.69.222 -j ACCEPT
iptables -A INPUT -s 219.87.170.253 -j ACCEPT
iptables -A INPUT -s 125.228.50.228 -j ACCEPT
iptables -A INPUT -s 218.161.107.138 -j ACCEPT
```
## 配置文件格式
@@ -73,6 +79,7 @@ geo $allowed_ip {
211.72.69.222 1;
219.87.170.253 1;
125.228.50.228 1;
218.161.107.138 1;
}
# 在 server 區塊中使用
@@ -93,6 +100,7 @@ Allow from 220.132.236.89
Allow from 211.72.69.222
Allow from 219.87.170.253
Allow from 125.228.50.228
Allow from 218.161.107.138
```
## 程式碼格式
@@ -106,7 +114,8 @@ ALLOWED_IPS = [
"220.132.236.89", # 新竹
"211.72.69.222", # 新竹
"219.87.170.253", # 璟茂
"125.228.50.228" # 璟茂
"125.228.50.228", # 璟茂
"218.161.107.138" # 新增IP
]
```
@@ -119,10 +128,22 @@ const allowedIPs = [
"220.132.236.89", // 新竹
"211.72.69.222", // 新竹
"219.87.170.253", // 璟茂
"125.228.50.228" // 璟茂
"125.228.50.228", // 璟茂
"218.161.107.138" // 新增IP
];
```
## 環境變數配置
### .env.local 配置
```env
# 啟用IP白名單
ENABLE_IP_WHITELIST=true
# 允許的IP地址包含新增的IP
ALLOWED_IPS=114.33.18.13,125.229.65.83,60.248.164.91,220.132.236.89,211.72.69.222,219.87.170.253,125.228.50.228,218.161.107.138
```
## 安全建議
1. **定期更新**建議定期檢查和更新IP地址清單