WAD 进程 Debug
WAD 进程 Debug
在生产环境中进行 WAD 相关调试时,应结合客户端侧的精确代理访问控制,以及 FortiGate/FortiProxy 上对 WAD Debug 的严格过滤策略,既能满足问题定位需求,又能最大限度降低对设备性能和业务的影响。
- FortiGate/FortiProxy 很多功能依赖 wad 进程来实现,很多时候需要使用 diag wad debug 来诊断故障。
- 但是 WAD Debug 的输出量很大,很容易造成设备 CPU 100%,甚至造成业务故障。
- 所以对 WAD Debug 做最细颗粒度的过滤是非常有必要的。
在进行 WAD 进程的 Debug 时,应注意如下事项:
- 控制客户端只有单个页面通过代理进行访问,而不是整机。方便 WAD Debug。
- 在 FortiGate/FortiProxy 精确限制 WAD Debug 的源 IP 和分类。
WAD Debug 举例
FortiGate 配置
配置代理功能,这里以 HTTP 显式代理端口 8080 为例。配置代理策略放通访问 Internet 的流量。
config web-proxy explicit
set status enable
set http-incoming-port 8080
set https-incoming-port 8080
end
config firewall proxy-policy
edit 1
set name "web_proxy_internet"
set proxy explicit-web
set dstintf "wan1"
set srcaddr "192.168.100.0/24"
set dstaddr "all"
set service "webproxy"
set action accept
set schedule "always"
next
end客户端配置
为客户端(192.168.100.99)浏览器(这里以 Chrome 为例)安装 ZeroOmega 插件(Edge 可以通过微软商店安装)。
插件安装成功后,在扩展程序设置(
chrome://extensions/?id=pfnededegaaopdmhkdmcofjmoldfiped,Edge 为edge://extensions/?id=pfnededegaaopdmhkdmcofjmoldfiped)中,建议将其固定到工具栏,并开启“在无痕模式下启用”。
点击 ZeroOmega 插件图表,点击“选项”按钮。

点击“新建情景模式”按钮,填写“情景模式名称”,选择类型为“代理服务器”,然后点击“创建”按钮。

填写代理服务器地址、端口、认证信息(如需),然后点击“应用选项”。

关闭客户端系统的代理。
Windows在开始菜单中输入“Internet 选项”,点击搜索结果中的“Internet 选项”按钮。

在“连接”选项卡中点击“局域网设置 (L)”按钮,关闭代理服务器配置,然后点击确定按钮。

macOS打开“系统设置 → 网络”,点击上网使用的网卡,点击“详细信息”,点击“代理”选项,关闭所有的代理配置。

WAD Debug 过程
使用 SSH 登录 FortiGate/FortiProxy 并执行 Debug(建议开启终端软件的日志记录),注意限制 Debug 的过滤条件。
diagnose debug reset diag debug console timestamp enable diagnose wad filter src 192.168.100.177 <----必须 diagnose wad debug enable level verbose diagnose wad debug enable category policy <----按需,打印策略匹配相关Debug diagnose wad debug enable category dns <----按需,打印DNS proxy相关Debug diagnose wad debug enable category http <----按需,打印HTTP代理相关Debug diagnose debug enable在 Chrome 中打开新的无痕窗口,等待浏览器自身更新/推送/主页广告等会话结束,约 5 分钟。

在 Chrome 浏览器的无痕窗口中点击“ZeroOmega”插件按钮,选择上文创建的代理情景模式。

在 Chrome 浏览器的无痕窗口访问:
https://community.fortinet.com.cn。在 FortiGate 上查看 WAD 的 Debug 信息,可以看到 FortiGate 只会记录特定过滤条件的 Debug 日志。
[V]2025-11-28 21:22:22.595455 [p:22145][s:11400441] wad_nontp_cache_make :2169 Matched webproxy object web-proxy [I]2025-11-28 21:22:22.595497 [p:22145][s:11400441] wad_http_srv_selector_static_make :1205 make static server selector. [I]2025-11-28 21:22:22.595506 [p:22145][s:11400441] wad_http_full_ses_make :18278 make ok session=0x7f7198f66450 server=(nil). [V]2025-11-28 21:22:22.595612 [p:22145][s:11400441] wad_http_mstrm_read_buff :1742 hs=0x7f7198fc5d78 mstrm=0x7f7198fc5da8 is_clt=1 len=250 [V]2025-11-28 21:22:22.595633 [p:22145][s:11400441][r:585] wad_http_req_alloc :1751 req=0x7f71a00e2cc0(ses_ctx:x|Phx|M|Hh|C|A7|O) dst(orig=192.168.81.89:8080 dst=192.168.81.89:8080 srv=) hs=0x7f7198fc5d78 clt_port=0x7f719b9df8d8 svr_port=(nil) [V]2025-11-28 21:22:22.595641 [p:22145][s:11400441][r:585] wad_http_req_line_reader_parse :624 request line method_len=7 url_len=26 ver_len=8 len=45 [V]2025-11-28 21:22:22.595648 [p:22145][s:11400441][r:585] __wad_http_clt_read_req_line :1981 http client request line clt=0x7f7198fc5da8 [V]2025-11-28 21:22:22.595651 [p:22145][s:11400441][r:585] wad_http_hdr_reader_parse :1232 header line len=34 name_len=4 val_len=26 is_piggy=0 invalid=0 [V]2025-11-28 21:22:22.595657 [p:22145][s:11400441][r:585] wad_http_msg_read_hdr :936 header name=Host: id=41 invalid=0. [V]2025-11-28 21:22:22.595660 [p:22145][s:11400441][r:585] wad_http_hdr_reader_parse :1232 header line len=30 name_len=16 val_len=10 is_piggy=0 invalid=0 [V]2025-11-28 21:22:22.595663 [p:22145][s:11400441][r:585] wad_http_msg_read_hdr :936 header name=Proxy-Connection: id=62 invalid=0. [V]2025-11-28 21:22:22.595665 [p:22145][s:11400441][r:585] wad_http_hdr_reader_parse :1232 header line len=139 name_len=10 val_len=125 is_piggy=0 invalid=0 [V]2025-11-28 21:22:22.595669 [p:22145][s:11400441][r:585] wad_http_msg_read_hdr :936 header name=User-Agent: id=85 invalid=0. [V]2025-11-28 21:22:22.595671 [p:22145][s:11400441][r:585] wad_http_hdr_reader_parse :1237 empty line. [I]2025-11-28 21:22:22.595675 [p:22145][s:11400441][r:585] wad_dump_http_request :2897 hreq=0x7f71a00e2cc0 Received request from client: 192.168.100.178:12918 CONNECT community.fortinet.com:443 HTTP/1.1 Host: community.fortinet.com:443 Proxy-Connection: keep-alive User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0 [I]2025-11-28 21:22:22.595687 [p:22145][s:11400441][r:585] wad_http_str_canonicalize :2200 enc=0 path=/ len=1 changes=0 [I]2025-11-28 21:22:22.595700 [p:22145][s:11400441][r:585] wad_http_conn_req_classify :6393 no security profile HTTPS/HTTP, tport=443 [V]2025-11-28 21:22:22.595708 [p:22145][s:11400441][r:585] _wad_url_match_find :151 Empty url-matcher! [V]2025-11-28 21:22:22.595735 [p:22145][s:11400441][r:585] wad_http_req_check_dns :81 hn=0x7f719ce07ba8 sn=(nil) [I]2025-11-28 21:22:22.595740 [p:22145][s:11400441][r:585] wad_http_dns_resolve :8874 [0x7f71a00e2cc0] DNS request name=community.fortinet.com len=22 type/pref/pref-strict=2/0/0 [I]2025-11-28 21:22:22.595756 [p:22145][s:11400441][r:585] wad_dns_req_msg_send_local_req :245 send unreq to dnsproxy. msg_len=40, type=wad_local_client_req, vfid=0, vrf=0, ifindex=3, policy_id=0 src_addr=192.168.100.178[I]2025-11-28 21:22:22.595760 [p:22145][s:11400441][r:585] wad_dns_req_msg_send_local_req :245 send unreq to dnsproxy. msg_len=40, type=wad_local_client_req, vfid=0, vrf=0, ifindex=3, policy_id=0 src_addr=192.168.100.178[V]2025-11-28 21:22:22.595764 [p:22145][s:11400441][r:585] wad_http_msg_strm_pause :1119 strm paused, flag=0x2 is_clt=1 [V]2025-11-28 21:22:22.595766 [p:22145][s:11400441][r:585] wad_http_clt_read_sync :2076 hs=0x7f7198fc5d78 pause=(1/0x2) ret=1 execute=wad_http_clt_read_req_line [I]2025-11-28 21:22:22.730740 [p:22145] wad_dnsproxy_conn_proc_common_hdr :626 msg_len=186 msg_type=11 session_id=0 [I]2025-11-28 21:22:22.730762 [p:22145] wad_dnsproxy_conn_proc_hdr :603 msg_len=186 msg_type=11 session_id=0 [I]2025-11-28 21:22:22.730772 [p:22145][s:11400441][r:585] wad_http_dns_request_done :14108 [0x7f71a00e2cc0] DNS resolved: 52.84.20.38 [V]2025-11-28 21:22:22.730789 [p:22145][s:11400441][r:585] wad_http_msg_strm_resume :1142 strm resumed, execute=wad_http_clt_read_req_line is_clt=1 [V]2025-11-28 21:22:22.730808 [p:22145][s:11400441][r:585] wad_http_req_get_dst_intf :13830 vd=0 dst=52.84.20.38 ifidx=3 [V]2025-11-28 21:22:22.730811 [p:22145][s:11400441][r:585] wad_http_req_proc_dst :14026 HTTP req=0x7f71a00e2cc0 check destination/quarantine ret=0 [V]2025-11-28 21:22:22.730817 [p:22145][s:11400441][r:585] wad_http_req_check_policy :13700 start match policy vd=0(ses_ctx:x|Phx|M|Hh|C|A7|O) (192.168.100.178:12918@3->52.84.20.38:443@3) absUrl=1 [I]2025-11-28 21:22:22.730829 [p:22145][s:11400441][r:585] wad_fast_match_is_enable :4031 fast matching is enabled [V]2025-11-28 21:22:22.730834 [p:22145][s:11400441][r:585] wad_fast_match_get_addr :3739 Get key src:192.168.100.178 [V]2025-11-28 21:22:22.730837 [p:22145][s:11400441][r:585] wad_fast_match_get_dst_intf :3769 Get key dst intf:2 [V]2025-11-28 21:22:22.730840 [p:22145][s:11400441][r:585] wad_fast_match_pol_array :3806 Try to maching pol:1, 0/1(pos/sz) [I]2025-11-28 21:22:22.730844 [p:22145][s:11400441][r:585] wad_fw_policy_async_match :7632 pol_ctx:xhcf|Ad|7?|=d [I]2025-11-28 21:22:22.730849 [p:22145][s:11400441][r:585] wad_http_req_policy_set :11730 match policy-id=1(pol_ctx:xhcf|Ad|7?|=d) vd=0(ses_ctx:x|Phx|Mde|Hh|C|A7|O) (192.168.100.178:12918@3 -> 52.84.20.38:443@3)Debug 结束后关闭所有 Debug 进程。
diagnose debug disable diagnose debug rest