先申请华为云账号,然后给账户充值。

一、云资源创建
(一)创建ECS实例


创建两个ECS,一个部署website,使用nginx代理;一个部署docker安装safeline。

| 角色 | 私网IP | 公网IP | 部署软件 | CPU | 内存 | 硬盘 |
|---|---|---|---|---|---|---|
| 网站站点 | 192.168.0.200 | 120.46.94.197 | nginx | 2 | 2 | 20 |
| 长亭雷池 | 192.168.0.140 | 120.46.94.197 | docker+safeline | 2 | 4 | 20 |
搭建这两个ECS实例,申请一个公网IP,然后在网上挂了10个小时,估计大概花了8元。
(二)调整ECS规格
修改ECS实例大小(CPU、内存)必须重启服务器。



(三)申请弹性公网IP

购买一个弹性公网IP就行,虽然同时只能绑定给一个ECS实例,但是可以解绑换绑给另外一个实例使用上网下载软件。
1、绑定弹性公网IP



2、解绑弹性公网IP


二、搭建websitenginx
ECS【192.168.0.200】绑定公网IP120.46.94.197后去下载nginx。


(一)安装nginx
bash
dnf install -y nginx #安装nignx
systemctl start nginx #启动nignx
systemctl enable nginx #设置开机自启动
(二)创建一个静态web界面
bash
mkdir -p /var/www/mysite #创建一个目录
nano /var/www/mysite/index.html #创建一个界面,写入下面代码
html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>登录</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
"Microsoft YaHei", sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
width: 340px;
padding: 40px 32px 32px;
background: #ffffff;
border-radius: 14px;
box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
}
.login-card h1 {
font-size: 22px;
font-weight: 600;
color: #2d3748;
text-align: center;
margin-bottom: 28px;
}
.field {
margin-bottom: 18px;
}
.field label {
display: block;
font-size: 13px;
color: #4a5568;
margin-bottom: 6px;
}
.field input {
width: 100%;
height: 42px;
padding: 0 12px;
font-size: 14px;
color: #2d3748;
background: #f7fafc;
border: 1px solid #e2e8f0;
border-radius: 8px;
outline: none;
transition: border-color .2s, background .2s, box-shadow .2s;
}
.field input::placeholder {
color: #a0aec0;
}
.field input:focus {
background: #fff;
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, .18);
}
.login-btn {
width: 100%;
height: 44px;
margin-top: 10px;
font-size: 15px;
font-weight: 500;
color: #fff;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border: none;
border-radius: 8px;
cursor: pointer;
transition: opacity .2s, transform .1s;
}
.login-btn:hover {
opacity: .9;
}
.login-btn:active {
transform: scale(.98);
}
</style>
</head>
<body>
<form class="login-card" onsubmit="return false;">
<h1>天赐系统管理后台</h1>
<div class="field">
<label for="account">账号</label>
<input id="account" type="text" placeholder="请输入账号" autocomplete="username">
</div>
<div class="field">
<label for="password">密码</label>
<input id="password" type="password" placeholder="请输入密码" autocomplete="current-password">
</div>
<button class="login-btn" type="submit">登 录</button>
</form>
</body>
</html>
(三)修改nginx配置文件
编辑/etc/nginx/nginx.conf,定位到第42行。
bash
/usr/share/nginx/html; 更改为/var/www/mysite;
bash
vim /etc/nginx/nginx.conf
38 server {
39 listen 80;
40 listen [::]:80;
41 server_name _;
42 root /usr/share/nginx/html; 更改为/var/www/mysite
43
44 # Load configuration files for the default server block.
45 include /etc/nginx/default.d/*.conf;
46
47 error_page 404 /404.html;
48 location = /404.html {
49 }
50
51 error_page 500 502 503 504 /50x.html;
52 location = /50x.html {
53 }
54 }
bash
nginx -t #测试 nginx 配置文件的语法是否正确
systemctl reload nginx #nginx配置生效,重新加载
直接登录一下站点:http://120.46.94.197/,是可以访问到的。

三、搭建雷池safeline
ECS【192.168.0.140】绑定弹性公网IP120.46.94.197,下载docker,然后下载safeline。
(一)部署docker
1、安装 DNF 插件
用于管理软件仓库。
bash
dnf install -y dnf-plugins-core
2、添加 Docker CE 稳定版仓库:
推荐使用 RHEL 版本的仓库,它在 Rocky Linux 9 上兼容性最好。
bash
dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
3、验证仓库已添加
执行以下命令,应能看到 docker-ce-stable
bash
dnf repolist | grep docker
4、安装 Docker 核心组件、CLI 工具、容器运行时以及常用的 Buildx 和 Compose 插件。
bash
dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
安装过程中可能会提示确认 Docker 的 GPG 密钥,验证指纹后接受即可。
5、启动并设置开机自启
bash
systemctl start docker
systemctl enable docker
docker --version
确认服务状态,输出应为 active:
bash
systemctl is-active docker
(二)部署safeline【长亭雷池】
1、安装safeline
bash
bash -c "$(curl -fsSLk https://waf-ce.chaitin.cn/release/latest/manager.sh)"
账号密码体现在安装过程,密码是随机生成:admin/UBd9zQn3

登录http://120.46.94.197:9443,可以管理雷池。
2、配置华为云安全组
开放ECS实例safeline 的8080端口,safeline也要开放一下9443端口用来登录web配置界面,后面再关闭。



3、防护应用
当前safeline【192.168.0.140】和website【192.168.0.200】是两台机器,直接配置反向代理防护模式。在这个场景下,website不会直接暴露在互联网上,是比较安全的。
弹性公网IP120.46.94.197,绑定给ECS【safeline】,本地监听8080,代理ECS【website】监听的80端口。



四、实验
(一)访问测试页面
http://120.46.94.197:8080/【这是代理端口】

(二)XSS测试
访问:http://120.46.94.197:8080/?"'html=' >

(三)safeline查看攻击日志
