2017-11-13 3 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을 사용하고 있기 때문에.

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 

또한 당신이 경로를 사용하고, 그 쿼리에 포함되지 않습니다

당신은 stroe이 같은 URL이 필요합니다. found 방법으로 url 또는 query (임베드 됨)을 사용해야 할 수도 있습니다. 당신은 아이디어를 얻습니다.

1

실제하고있는 것에는 두 가지 문제점이 있습니다.

먼저 path 가져 오기는 응답 처리가 아닌 요청 처리 중에 만 사용할 수 있습니다. 이것이 경고의 이유입니다. path에는 자체 버퍼가 할당되지 않습니다. 페치는 평가 될 때마다 보류중인 요청 버퍼에서 페치를 추출하고 보류중인 요청 버퍼는 요청이 서버로 전송되는 즉시 해제됩니다.

둘째, ?으로 시작하는 모든 항목은 이 아니며 부분입니다. 그것이 쿼리 문자열입니다.

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 대한 올바른 철자를 참고.

관련 문제