随笔——Day 2

随笔——Day 2

  • F5替换Nginx上的配置
    • Nginx上的配置
    • F5上对应的iRule

F5替换Nginx上的配置

昨天有提到,遇到了一个客户需求,将Nginx上的配置更换为F5上的配置,今天把F5上的iRules憋出来了;

Nginx上的配置

 location /get {
            proxy_pass https://abc;
            proxy_redirect off;
            proxy_method GET;
proxy_set_header authorization "efg";
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Content-Type  "image/jpg";
        }

对应的理解应该是这样的:
首先是收到了客户端的请求,然后将客户端的请求的URL替换为https://abc;然后在头部中插入efg;插入X-Forword-For,插入客户端的真实IP;头部插入Content-Type为image/jpg;

F5上对应的iRule

when HTTP_REQUEST { 
    switch -glob string tolower [HTTP::uri] {
"/" { HTTP::uri "https://abc" }
set authorization_id [HTTP::header value "efg"]
         HTTP::header insert X-Forwarded-For [IP::client_addr]
         HTTP::header replace "Content-Type" "image/jpeg"
}      
}

以上纯属个人的理解,有不对的地方还请各位大神们指出来。

你可能感兴趣的:(随笔——Day 2)