Appearance
绑定公网 IP / 弹性公网 IP
登录实例
绑定公网 IP 后即可远程连接云服务器。
环境准备
在实例上安装 Nginx:
bash
# 安装并启动 Nginx
apt update
apt -y install nginx
接入流程
开启 WAF(Web 应用防火墙)
配置 DNS 解析接入
在阿里云解析中添加 WAF 接入 CNAME:
修改 DNS 记录:
检测 DNS:
效果测试
修改 Nginx access.log
日志格式,输出 WAF 字段
查看配置:
bash
egrep -v '^$|#' /etc/nginx/nginx.conf
配置内容(节选):
nginx
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
'"$http_waf" "$http_lidao"';
access_log /var/log/nginx/access.log main;
...
}
查看访问日志:
bash
cat /var/log/nginx/access.log
输出示例:
114.215.255.206 - - [07/Apr/2025:14:45:24 +0800] "GET / HTTP/1.1" 200 612 "-" "curl/7.81.0" "-""waf_test" "lidao_test"
121.40.17.37 - - [07/Apr/2025:14:45:54 +0800] "GET / HTTP/1.1" 200 612 "-" "curl/7.81.0" "-""waf_test" "lidao_test"
检查 DNS 解析
bash
nslookup www.linuxpath.cn
输出示例:
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
www.linuxpath.cn canonical name = www.linuxpath.cn.c.yundunwaf4.com.
Name: www.linuxpath.cn.c.yundunwaf4.com
Address: 8.139.55.97
WAF 防护规则配置
设置白名单
设置自定义规则
浏览器访问测试
使用 Edge 浏览器访问测试页面: