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

Where can ALLOWED_HOSTS be changed for testing? #354

Closed
sdbbs opened this issue Nov 30, 2021 · 2 comments
Closed

Where can ALLOWED_HOSTS be changed for testing? #354

sdbbs opened this issue Nov 30, 2021 · 2 comments
Labels

Comments

@sdbbs
Copy link

sdbbs commented Nov 30, 2021

I am trying out jawanndenn on own server, but I cannot quite get it to work.

I set up jawanndenn inside a virtualenv, where it was installed with pip3 install jawanndenn; then, I try to test it with:

$ JAWANNDENN_ALLOWED_HOSTS="mysite.com" jawanndenn --host 0.0.0.0 --port 6789

Then, when I fire up the browser at mysite.com:6789, I get Bad Request (400) in the browser, and the server terminal reports:

Invalid HTTP_HOST header: 'mysite.com:6789'. You may need to add 'mysite.com' to ALLOWED_HOSTS (['0.0.0.0', '127.0.0.1', '0.0.0.0', 'localhost']).
XX.YY.ZZ.WW- - [30/Nov/2021:11:37:59 +0000] "GET / HTTP/1.1" 400 143 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0"

Eh, however, I added it here in ALLOWED_HOSTS already:

jawanndenn/lib/python3.8/site-packages/jawanndenn/settings.py:    'mysite.com',
jawanndenn/lib/python3.8/site-packages/django/conf/global_settings.py:ALLOWED_HOSTS = [ "mysite.com" ]

... and I still get the above message.

Any suggestions how can I get this running for testing?

@sdbbs
Copy link
Author

sdbbs commented Nov 30, 2021

Ok, I think I've figured it out - note that I have no Django installed standalone on the server - only pip3 install jawanndenn.

First of all, setting the environment variable JAWANNDENN_ALLOWED_HOSTS in the shell is useless - because it is explicitly set in ./jawanndenn/lib/python3.8/site-packages/jawanndenn/__main__.py:

    os.environ['JAWANNDENN_ALLOWED_HOSTS'] = ','.join([options.host,
                                                       '127.0.0.1',
                                                       '0.0.0.0',
                                                       'localhost'])

However, we have the options.host there - and that is exactly the string passed on via the --host option/switch. So, I could finally start like this:

jawanndenn --host mysite.com --port 6789

... and then when I visit mysite.com:6789 in the browser, jawanndenn works fine and I can test it.

@hartwork
Copy link
Owner

Sounds like you figured things out already, I'll close this as "answered" 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants