2017-11-27 5 views
0

デスクトップ/モバイルウェブサイトをシングルワニスマシンで設定したいと考えています。各ウェブサイト、つまりモバイル版とデスクトップ版には複数のウェブサーバーがあります。だから、私は、デスクトップ版のPOSTリクエストを行う際にリクエストが正常に動作してGETしながら、今ではモバイルサイトのディレクターに送信する私はニス5.Xにワニスで複数のラウンドロビンディレクター

backend wap1 { .host = "xxx.xxx.xxx.xxx"; .port = "80"; 
.connect_timeout = 5s; .first_byte_timeout = 5s; .between_bytes_timeout = 2s; } 
backend wap2 { .host = "xxx.xxx.xxx.xxx"; .port = "80"; 
.connect_timeout = 5s; .first_byte_timeout = 5s; .between_bytes_timeout = 2s; } 

backend web1 { .host = "xxx.xxx.xxx.xxx"; .port = "80"; 
.connect_timeout = 5s; .first_byte_timeout = 5s; .between_bytes_timeout 
= 2s; } 
backend web2 { .host = "xxx.xxx.xxx.xxx"; .port = "80"; 
.connect_timeout = 5s; .first_byte_timeout = 5s; .between_bytes_timeout 
= 2s; } 

sub vcl_init { 
new active_wap_rr = directors.round_robin(); 
new active_web_rr = directors.round_robin(); 
active_wap_rr.add_backend(wap1); 
active_wap_rr.add_backend(wap2); 
active_web_rr.add_backend(web1); 
active_web_rr.add_backend(web2); 
} 

if (req.http.host == "m.example.com") { 
    set req.backend_hint = active_wap_rr.backend(); 
}else if(req.http.host == "www.example.com" || req.http.host == "example.com") { 
    set req.backend_hint = active_web_rr.backend(); 
} 

を使用しています

以下のような複数の取締役を定義しています。

ご意見やご提案をいただければ幸いです。 POSTメソッドをチェックして定義されたバックエンドのヒントをバックエンドないようにパスを戻しながらこれは次の理由コード

if (req.host == "m.example.com") { 
    if(req.method == "POST"){ 
      return (pass); 
    } 
}else if (req.host == "www.example.com" || req.host == "example.com") { 
     if(req.method == "POST"){ 
      return (pass); 
     } 
} 

とコード以下のhappingた

おかげ

答えて

0

は、バックエンド・ヒント

if (req.http.host == "m.example.com") { 
    set req.backend_hint = active_wap_rr.backend(); 
}else if(req.http.host == "www.example.com" || req.http.host == 
"example.com") { 
    set req.backend_hint = active_web_rr.backend(); 
} 

を割り当て最初に定義されたバックエンドを取っていました。

正しい方法は

if (req.host == "m.example.com") { 
    set req.backend_hint = active_wap_rr.backend(); 
    if(req.method == "POST"){ 
      return (pass); 
    } 
}else if (req.host == "www.example.com" || req.host == "example.com") { 
     set req.backend_hint = active_web_rr.backend(); 
     if(req.method == "POST"){ 
      return (pass); 
     } 
} 

されており、コードの下にバックエンドを割り当てるために必要とされていません。