NETWORK ENGINEER BLOG

Tips and Reviews for Engineers

BIG-IP のヘルスチェックで User-Agent を定義する

User-Agent ヘッダについて

Web サーバと HTTP/HTTPS で通信する Web ブラウザやアプリ、クローラーといったクライアントプログラムは、Web サーバにリクエストを送る際、自身の「素性」を表す情報も同時に送信する。そのために使われるヘッダを「User-Agent ヘッダ」と呼ぶ。また「素性」を表した文字列のことを、「ユーザーエージェント文字列」と呼ぶ。
f:id:FriendsNow:20210224214428p:plain:w600
出典:@IT

ヘルスチェックで User-Agent を設定

BIG-IP では HTTP のヘルスチェックに User-Agent を定義する事が可能です。

Monitor の作成

User-Agent が定義された monitor1 を作成

(tmos)# create ltm monitor http monitor1
(tmos)# modify ltm monitor http monitor1 destination *:* interval 5 recv "200 OK" send "GET / HTTP/1.0\\r\\nUser-agent: User-Agent-Test\\r\\n\\r\\n" time-until-up 0 timeout 16

Monitor の確認

(tmos)# show running-config ltm monitor
ltm monitor http monitor1 {
    defaults-from http
    destination *:*
    interval 5
    recv "200 OK"
    send "GET / HTTP/1.0\\r\\nUser-agent: User-Agent-Test\\r\\n\\r\\n"
    time-until-up 0
    timeout 16
}

GUI で設定する場合は下記のとおり
f:id:FriendsNow:20140515113347p:plain

Pool の作成

Pool 作成と monitor1 の関連付け

(tmos)# create ltm pool pool1
(tmos)# modify ltm pool pool1 members add { 192.168.100.1:http { address 192.168.100.1 } } monitor monitor1

Pool の確認

(tmos)# show running-config ltm pool pool1
ltm pool pool1 {
    members {
        192.168.100.1:http {
            address 192.168.100.1
            session monitor-enabled
            state up
        }
    }
    monitor monitor1
}

サーバで User-Agent が定義された HTTP リクエストを受信している事を確認

> tcpdump -i eth1 -s 1024 -A dst 192.168.100.1 and port 80
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 1024 bytes
08:17:12.102234 IP 192.168.100.254.56048 > 192.168.100.1.http: S 3813966378:3813966378(0) win 14600 <mss 1460,sackOK,timestamp 4216260931 0,nop,wscale 7>
E..<.4@.@.j7..d...d....P.T.*......9..T.........
.O      C........
08:17:12.145874 IP 192.168.100.254.56048 > 192.168.100.1.http: . ack 3041341077 win 115 <nop,nop,timestamp 4216260950 2122782>
E..4.5@.@.j>..d...d....P.T.+.G.....s.w.....
.O      V. d.
08:17:12.145882 IP 192.168.100.254.56048 > 192.168.100.1.http: P 0:47(47) ack 1 win 115 <nop,nop,timestamp 4216260950 2122782>
E..c.6@.@.j...d...d....P.T.+.G.....s.......
.O      V. d.GET / HTTP/1.0
User-agent: User-Agent-Test  <--- BIG-IP で定義した文字列を確認

以上