Mathics3 / mathics-omnibus

Docker setup for to tie together a number of mathics libraries, and components: Mathics3, mathicsscript, Mathics-Django, etc. This is useful in dockerization or PyPI packaging of a more complete collection.
GNU General Public License v3.0
24 stars 4 forks source link

Invalid HTTP_HOST header #11

Closed MohamedElashri closed 1 year ago

MohamedElashri commented 2 years ago

Hello

There is a problem with using the docker image on any public instance. You will get an error like that.

Invalid HTTP_HOST header: '<ip>:8000'. You may need to add '<ip>' to ALLOWED_HOSTS.
Bad Request: /

I think you will need a way to specify ALLOWED_HOSTS = ['*'] in Django settings.py by default if we are using docker.

TiagoCavalcante commented 2 years ago

@MohamedElashri how did you setup the instance?

MohamedElashri commented 2 years ago

I did it via docker run --rm -it --name mathics-web -p 8000:8000 -v /tmp:/usr/src/app/data mathicsorg/mathics --mode ui

rocky commented 2 years ago

Ok - thanks for the information. I guess we need to change the Django side .

I will try to get this all fixed up within a week or so

rocky commented 2 years ago

@MohamedElashri Mathics-django master at https://github.com/Mathics3/mathics-django/commit/ab98c70f2d7ae87a89956760a13361757c4863a6 has been updated to allow setting ALLOWED_HOSTS via an environment variable. Please try it when you get a chance.

What remains here is just to allow passing new environment variables through.

MohamedElashri commented 2 years ago

Hello, That's great. However, this problem comes with docker, so we need to allow passing new environment variables (and build the image) before it can be tested.

rocky commented 2 years ago

I had intended to look at this, but I might not be able to get around to this. This kind of thing is pretty straightforward to add, and the existing code has a pattern to follow. Also, this is open-source code which means anyone can contribute.

Maybe you can try adding and putting in a PR?

(A trepidation I have here though is that the API is a little unstable right now - so fixing this up just might open the flood gates for that, unless you work with the last packaged versions)

rocky commented 1 year ago

@MohamedElashri - Please let me know if #12 fixes things with the current master of Mathics Django.