Repository: WeblateOrg/weblate

Issue:
Allow setting Django USE_X_FORWARDED_HOST in `settings_docker.py`
### Describe the problem

It is documented [here](https://docs.weblate.org/en/latest/admin/install.html#running-behind-reverse-proxy) that:
> Additional configuration might be needed in your reverse proxy (for example use ProxyPreserveHost On for Apache or proxy_set_header Host $host; with nginx).

Altought this is a solution, it is sometimes difficult to adjust the proxy settings.

### Describe the solution you'd like

It would be nicer to be able to configure Weblate to use an "X-Forwarded-Host" header which is often supplied.
This is supported by Django with the [USE_X_FORWARDED_HOST](https://docs.djangoproject.com/en/4.1/ref/settings/#use-x-forwarded-host) setting.
This setting isn't currently exposed in the `settings_docker.py` so it can't be set with environment variables.

### Describe alternatives you've considered

Building a custom docker image with a custom `settings.py` which exposes the setting.
Or alternatively mounting a custom `settings.py` into the running container to expose it.

### Screenshots

_No response_

### Additional context

_No response_


Discussion:
You can customize the settings.py without rebuilding the image, see https://docs.weblate.org/en/latest/admin/install/docker.html#overriding-settings-from-the-data-volume.

Exposing USE_X_FORWARDED_HOST in environment seams reasonable way to go.
This issue seems to be a good fit for newbie contributors. You are welcome to contribute to Weblate! Don't hesitate to ask any questions you would have while implementing this.

You can learn about how to get started in our [contributors documentation](https://docs.weblate.org/en/latest/contributing/index.html).
> You can customize the settings.py without rebuilding the image, see https://docs.weblate.org/en/latest/admin/install/docker.html#overriding-settings-from-the-data-volume.

Oh thanks, I was looking at that page, but never saw it because of the huge list of configuration options above it.
I assumed the rest of the file was just a listing and didn't see that there was additional documentation below.

It's mentioned in the beginning as well (https://docs.weblate.org/en/latest/admin/install/docker.html#docker-environment-variables), but suggestions how to make it easier to spot are welcome.
Hi @nijel  , I would like to work on this issue. Is the solution just exposing the environment variable USE_X_FORWARDED_HOST in dev-docker/environment file ?? Am i correct on this ?? I will be waiting for your response and start raising a PR once you give an approval on this. Thanks
It needs to be added to https://github.com/WeblateOrg/weblate/blob/main/weblate/settings_docker.py, you are welcome to contribute this.
@nijel thanks for your reply. Do you want me to add any default value for this environment variable ?? 
Yes, it should default to false as in Django, see how other boolean variables are handled in that file.
@nijel thanks for this. Have a nice day. Got it !!

Resolving patch:
diff --git a/weblate/settings_docker.py b/weblate/settings_docker.py
--- a/weblate/settings_docker.py
+++ b/weblate/settings_docker.py
@@ -1396,6 +1396,8 @@
 
 UNUSED_ALERT_DAYS = get_env_int("WEBLATE_UNUSED_ALERT_DAYS", 365)
 
+USE_X_FORWARDED_HOST = get_env_bool("WEBLATE_USE_X_FORWARDED_HOST", False)
+
 # Wildcard loading
 for name in os.environ:
     if name.startswith("WEBLATE_RATELIMIT_") and name.endswith(


Test patch: