使用具有HAproxy的Content-Security-Policy框架 - 祖先

时间:2017-04-25 21:35:23

标签: security iframe subdomain haproxy content-security-policy

我希望从www.example.comsubdomain1.example.com访问subdomain2.example.com中的内容我需要在HAproxy中将我的子域列入白名单。

当我在网上快速搜索时,我只有71 results。 (2017年4月)

我不确定如何在HAproxy配置中执行此操作。

rspadd Content-Security-Policy:\ frame-ancestors subdomain1.example.com subdomain2.example.com是正确的语法。

跟进:我还需要在下面添加吗?

rspadd X-Frame-Options:\ ALLOW-FROM subdomain1.example.com

rspadd X-Frame-Options:\ ALLOW-FROM subdomain2.example.com

1 个答案:

答案 0 :(得分:0)

请使用http-response set-header而不是rspadd。前者是更新,更灵活的命令集的一部分,后者主要是出于向后兼容的原因。

您想要创建一个如下所示的行:

http-response set-header Content-Security-Policy "frame-ancestors subdomain1.example.com subdomain2.example.com"

如果您想要更多安全策略参数,请在引号内用分号(;)后添加它们。 例如:

http-response set-header Content-Security-Policy "frame-ancestors subdomain1.example.com subdomain2.example.com; script-src 'self'; style-src https://subdomain1.example.com"

根据上下文的不同,您可以考虑在网站调用内容上使用child-src,而不是在被调用的源上使用frame-ancestors,而不是使用X-Content-Security-Policy

另请注意,目前,Internet Explorer需要一个单独的标头X-Frame-Options,其工作方式与“常规”CSP几乎相同,因此您可能希望定义这两个标头字段

ALLOW-FROM已被CSP淘汰,但仍可能出于向后兼容性原因而设置。 AFAIK Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/eghx/agent18/project-gym/tests/thresholding.py", line 34, in image_to_string2 print(image_to_string(img_open)) File "/home/eghx/anaconda3/lib/python3.6/site-packages/pytesseract-0.1.7-py3.6.egg/pytesseract/pytesseract.py", line 122, in image_to_string File "/home/eghx/anaconda3/lib/python3.6/site-packages/pytesseract-0.1.7-py3.6.egg/pytesseract/pytesseract.py", line 46, in run_tesseract File "/home/eghx/anaconda3/lib/python3.6/subprocess.py", line 709, in __init__ restore_signals, start_new_session) File "/home/eghx/anaconda3/lib/python3.6/subprocess.py", line 1344, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'tesseract': 'tesseract' 参数只占用一个源,因此根据上下文可能有点限制。

相关问题