tech note

インフラ技術や車についてつぶやいていくブログ

iRule

BIG-IP iRule デフォルトで用意されている「_sys_https_redirect」の動作解説

デフォルトで入っている以下iRuleの解説を _sys_https_redirect when HTTP_REQUEST { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] } getfieldってのは以下の通り文字列を区切り文字で割った何個目を参照するかですね。https://devcent…

BIG-IP iRule GeoLocationでACLする方法

まずこちらをインストールします。 tech.ioroi.net when CLIENT_ACCEPTED { if { [whereis [IP::client_addr] country] eq "JP"} { return } else { drop } } ※日本に制限する例[whereis ip_addr country] でカントリーコードを参照出来ます。

BIG-IP iRule HTTP redirectを302応答から301に変更する

こちらでリダイレクト設定しましたが、応答が302なのはおかしいので 301で応答するよう変更しました。 tech.ioroi.net 旧iRule iRule HTTP::redirect https://www.tech-memo.work[HTTP::uri] 結果 # curl -I https://www.sv-cat.net/1 HTTP/1.0 302 Found Lo…

BIG-IP iRule 小文字に合わせる

構文 string tolower tclshでの実行例 # tclsh % string tolower HOGE hoge iRule構文例 string tolower [HTTP::uri] 動作 /HOGE → /hogestring tolowerの引数に当たる文字を小文字化 上記構文例では、[HTTP::uri]を小文字に変えてます。 iRule例 when HTTP_…

BIG-IP iRule HTTPヘッダーを挿入するコマンド

コマンド HTTP::header insert <header名> <value値> DevCentral Member Login | F5 DevCentral 例 when HTTP_REQUEST { HTTP::header insert x-header 1 }</value値></header名>

Data Group ListのValueをiRuleで使う方法

以下Data Group Listがあったとします。 DG_list String Value hoge1 Pool1 hoge2 Pool2 Hostheaderに応じてPoolへバランシングできます。 when HTTP_REQUEST { if { [class match [HTTP:host] eq DG_list } { #hostがDG_listにあったら set Pool [ [class m…

BIG-IP iRule ワイルドカードにてURIを判定しPoolへバランシングする例(headerInsertも有り)

when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/hoge1/*.html" { pool Pool1 } "/hoge2/*.html" { pool Pool1 } default { pool Pool2 } } } さらにHTTPheaderを付与する when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri…

BIG-IP iRule matchclass 使い方

構文 when CLIENT_ACCEPTED { if { [matchclass [IP::remote_addr] equals aol] } { pool aol_pool } else { pool all_pool } } DataGroupListをClassといっており、そのClassとマッチするかを評価するコマンドです。 aolはデフォルトで用意されているDataGr…

BIG-IP iRule 指定時間にSorryサーバへリダイレクトするサンプル

毎日1~7時の間にSorryサーバーへリダイレクトするサンプルです when HTTP_REQUEST { set Now [clock format [clock seconds] -format %H] if {$Now >= 1 and $Now <= 7 }{ HTTP::redirect "http://sorry/xxxx/index.html" } }

BIG-IP iRule HTTP::respond によるリダイレクトHTTPヘッダー例

iRule記述とその結果 HTTP::respond 403 noserver Server Apache when HTTP_REQUEST { HTTP::respond 403 noserver Server Apache } -- HTTP/1.0 403 Forbidden Server: Apache Connection: Keep-Alive Content-Length: 0 HTTP::respond 403 noserver when H…

BIG-IPでSourceIPを用いてACLするiRule

ACLの書き方 VirtualServer宛通信でACLを掛ける際は、iRule+DataGroupListを用います。 iRule when CLIENT_ACCEPTED { if { [class match [IP::client_addr] equals home_net] }{ return } else { drop } } Data Group List ltm data-group internal home_ne…