2017-11-13 7 views
0

私はhaproxy 1.6.3を実行していますが、フロントフレームにはX-Frame-Originヘッダーが設定されています。私はサイトがiframeに読み込まれ、そのヘッダーのためにコンテンツがブロックされている状況に遭遇しました。私は以下のように見えるACLルールを設定することを試みた:異なるパス上のヘッダーを除外

acl is_embeded path_beg /?embeded=1 
http-response set-header x-frame-options "SAMEORIGIN" if !is_embeded 

は、私は私が次のエラーのためにhaproxy -f /etc/haproxy/haproxy.conf -c実行すると:

[WARNING] 316/145915 (23701) : parsing [/etc/haproxy/haproxy.cfg:42] : acl 'is_embeded' will never match because it only involves keywords that are incompatible with 'frontend http-response header rule' 

この作業を取得する方法はありますか?

答えて

0

レスポンスステージでリクエストaclを使用しているためです。あなたはこのようstroeにURLが必要

http-request set-var(txn.urlEmbeded) url 
acl is_embeded var(txn.urlEmbeded) -m beg /?embeded=1 
http-response set-header x-frame-options "SAMEORIGIN" if !is_embeded 

はまた、あなたがパスを使用している、それはクエリが含まれていません。 foundメソッドでurlまたはquery(埋め込み)を使用する必要があります。あなたはその考えを得る。

1

実際に行っていることには2つの問題があります。

最初に、pathフェッチは、要求処理中にのみ使用できます。応答処理は使用できません。これが警告の理由です。 pathには、独自のバッファが割り当てられていません。フェッチは、評価されるたびに保留中の要求バッファから取り出し、要求がサーバーに送信されるとすぐに保留中の要求バッファが解放されます。

第2に、?で始まるものはすべて、ではなく、のパスの一部です。これがクエリ文字列です。

capture.req.uriは、パスとクエリ文字列の両方を含んでおり、メモリバッファが割り当てられているため、要求処理中もそのまま使用されるため、正しいフェッチが使用されます。

acl is_embeded capture.req.uri -m beg /?embeded=1 

capture.req.uri

This extracts the request's URI, which starts at the first slash and ends before the first space in the request (without the host part). Unlike path and url , it can be used in both request and response because it's allocated.

http://cbonte.github.io/haproxy-dconv/1.6/configuration.html#7.3.6-capture.req.uri

はまた、単語embeddedのための正しいスペルに注意してください。

関連する問題