on master help sign in
[enh] add default http headers - closes #715
commit063260d090d175f010f42270664d476bb8039801 authorAdam Tauber <asciimoo@gmail.com> dateWed 4 Nov 2020, 17:32 (6 years ago) parentc03e4c8
2 files changed+16
searx/settings.yml+6 searx/webapp.py+10
searx/settings.yml+6
@@ -17,6 +17,12 @@ server:
1717 image_proxy : False # Proxying image results through searx
1818 http_protocol_version : "1.0" # 1.0 and 1.1 are supported
1919 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
2026
2127ui:
2228 static_path : "" # Custom static path - leave it blank if you didn't change
searx/webapp.py+10
@@ -487,6 +487,16 @@ def pre_request():
487487 request.user_plugins.append(plugin)
488488
489489
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+
490500@app.after_request
491501def post_request(response):
492502 total_time = time() - request.start_time