2015-04-19 35 views
6

具體網址我在HAProxy的配置有一個簡單的條件(我想這對於前端後端):添加標題,以響應與HAProxy的

acl no_index_url path_end .pdf .doc .xls .docx .xlsx 
rspadd X-Robots-Tag:\ noindex if no_index_url 

它應該增加無漫遊器標題到不應該編入索引的內容。

acl 'no_index_url' will never match because it only involves keywords 
    that are incompatible with 'backend http-response header rule' 

acl 'no_index_url' will never match because it only involves keywords 
    that are incompatible with 'frontend http-response header rule' 

documentationrspadd既可前端後端使用:然而,它解析配置的時候給我這個WARNINGpath_end用於前端內的示例中。爲什麼我得到這個錯誤,這是什麼意思?

回答

12

從HaProxy 1.6開始,您將無法忽略錯誤消息。爲了得到這個工作使用臨時變量功能:

frontend main 
    http-request set-var(txn.path) path 

backend local 
    http-response set-header X-Robots-Tag noindex if { var(txn.path) -m end .pdf .doc } 
+1

你救了我的一天:) – Yajo

1

顯然,即使發出警告,前端內的acl也可以很好地工作。所有與.pdf,.doc等資源都獲得正確的X-Robots-Tag添加到他們。

換句話說,這WARNING是誤導,並在現實中acl沒有匹配。

+0

只是一個對任何人碰到這個未來的音符,在1.6.2儘管警告它確實增加了頭,但也將其添加到任何響應不匹配的規則,所以我相信它實際上被忽略了。無論如何,對我來說就是這種情況,如果這有所作爲,我會使用'除非'。接受的答案爲我工作,所以試試。 – James