Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting Django USE_X_FORWARDED_HOST in settings_docker.py #8566

Closed
RedlineTriad opened this issue Jan 6, 2023 · 11 comments · Fixed by #9856
Closed

Allow setting Django USE_X_FORWARDED_HOST in settings_docker.py #8566

RedlineTriad opened this issue Jan 6, 2023 · 11 comments · Fixed by #9856
Assignees
Labels
enhancement Adding or requesting a new feature. good first issue Opportunity for newcoming contributors. hacktoberfest This is suitable for Hacktoberfest. Don’t try to spam. help wanted Extra attention is needed.
Milestone

Comments

@RedlineTriad
Copy link

Describe the problem

It is documented here 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 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

@nijel
Copy link
Member

nijel commented Jan 6, 2023

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.

@nijel nijel added enhancement Adding or requesting a new feature. hacktoberfest This is suitable for Hacktoberfest. Don’t try to spam. help wanted Extra attention is needed. good first issue Opportunity for newcoming contributors. labels Jan 6, 2023
@github-actions
Copy link

github-actions bot commented Jan 6, 2023

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.

@RedlineTriad
Copy link
Author

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.

@nijel
Copy link
Member

nijel commented Jan 6, 2023

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.

@Pavankumardontha
Copy link
Contributor

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

@nijel
Copy link
Member

nijel commented Sep 4, 2023

It needs to be added to https://github.com/WeblateOrg/weblate/blob/main/weblate/settings_docker.py, you are welcome to contribute this.

@Pavankumardontha
Copy link
Contributor

@nijel thanks for your reply. Do you want me to add any default value for this environment variable ??

@nijel
Copy link
Member

nijel commented Sep 4, 2023

Yes, it should default to false as in Django, see how other boolean variables are handled in that file.

@Pavankumardontha
Copy link
Contributor

@nijel thanks for this. Have a nice day. Got it !!

@Pavankumardontha
Copy link
Contributor

@nijel here is my PR. Please check and let me know if you require any more changes from my end. Thanks !!

@nijel nijel added this to the 5.0.1 milestone Sep 6, 2023
nijel added a commit that referenced this issue Sep 6, 2023
Fixes #8566

Co-authored-by: PavanKumar <dpavankumar@attentive.ai>
Co-authored-by: Michal Čihař <michal@cihar.com>
@github-actions
Copy link

github-actions bot commented Sep 6, 2023

Thank you for your report; the issue you have reported has just been fixed.

  • In case you see a problem with the fix, please comment on this issue.
  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding or requesting a new feature. good first issue Opportunity for newcoming contributors. hacktoberfest This is suitable for Hacktoberfest. Don’t try to spam. help wanted Extra attention is needed.
Projects
None yet
3 participants