on master help sign in
Merge pull request #2295 from searx/default-http-headers
aa6eaf6Noémi Ványi
searx/settings.yml+6
@@ -17,6 +17,12 @@ server:
17 image_proxy : False # Proxying image results through searx
17 image_proxy : False # Proxying image results through searx
18 http_protocol_version : "1.0" # 1.0 and 1.1 are supported
18 http_protocol_version : "1.0" # 1.0 and 1.1 are supported
19 method: "POST" # POST queries are more secure as they don't show up in history but may cause problems when using Firefox containers
19 method: "POST" # POST queries are more secure as they don't show up in history but may cause problems when using Firefox containers
20+ default_http_headers:
21+ X-Content-Type-Options : nosniff
22+ X-XSS-Protection : 1; mode=block
23+ X-Download-Options : noopen
24+ X-Robots-Tag : noindex, nofollow
25+ Referrer-Policy : no-referrer
20
26
21ui:
27ui:
22 static_path : "" # Custom static path - leave it blank if you didn't change
28 static_path : "" # Custom static path - leave it blank if you didn't change
searx/webapp.py+10
@@ -487,6 +487,16 @@ def pre_request():
487 request.user_plugins.append(plugin)
487 request.user_plugins.append(plugin)
488
488
489
489
490+@app.after_request
491+def add_default_headers(response):
492+ # set default http headers
493+ for header, value in settings['server'].get('default_http_headers', {}).items():
494+ if header in response.headers:
495+ continue
496+ response.headers[header] = value
497+ return response
498+
499+
490@app.after_request
500@app.after_request
491def post_request(response):
501def post_request(response):
492 total_time = time() - request.start_time
502 total_time = time() - request.start_time