Use X-Forwarded-Host as url_root when present
If Whoogle is accessed on a non-standard port _and_ proxied, this port is lost to the application and `element['src']`s are incorrectly formed (omitting port). HTTP x-Forwarded-Host will conain this front port number in a typical Nginx reverse proxy configuratoin.
This commit is contained in:
parent
c1d9373d55
commit
90cf2d7de3
|
@ -116,6 +116,14 @@ class Search:
|
|||
"""
|
||||
mobile = 'Android' in self.user_agent or 'iPhone' in self.user_agent
|
||||
|
||||
# reconstruct url_root if X-Forwarded-Host header present
|
||||
scheme = self.request.headers.get('X-Forwarded-Proto', 'http')
|
||||
http_host = self.request.headers.get('X-Forwarded-Host')
|
||||
if http_host:
|
||||
root_url = f'{scheme}://{http_host}/'
|
||||
else:
|
||||
root_url = self.request.url_root
|
||||
|
||||
content_filter = Filter(self.session_key,
|
||||
root_url=self.request.url_root,
|
||||
mobile=mobile,
|
||||
|
|
Loading…
Reference in New Issue
Block a user