I have created a Django project using Django Cookiecutter with Docker.
So far so good, but I keep getting a 400 error (Bad request).
When I look in the log on Sentry, I can see the message that I need to add the ip address 123.123.123.132 to allowed hosts.
In .env there is a variable DJANGO_ALLOWED_HOSTS, which by default contains the domain name that was entered when using Cookiecutter.
Some ways I have tried so far:
DJANGO_ALLOWED_HOSTS=.foo.bar,123.123.123.132
DJANGO_ALLOWED_HOSTS=.foo.bar 123.123.123.132
DJANGO_ALLOWED_HOSTS=[.foo.bar,123.123.123.132]
What syntax should I use here to make this work?
Thanks
From the Django documentation
You should try
ALLOWED_HOSTS = [".foo.bar" , "123.123.123.132"]
Related
in my rich body text fields, when an internal page is used for a link, the url that gets attached to the a tag is "https//example.com/example", ie it's missing the colon and the link doesnt work. I get the error "https's server ip address could not be found".
any idea why it is doing this? thanks
Check the site record under Sites -> Settings. The hostname field should NOT contain https - i.e. it should be example.com, not https://example.com.
in case anyone else has this issue, it seems having more than one site in wagtail caused this. I had the default localhost site still on there, even after switching to a new production site configuration. deleting the localhost site fixed this.
I have been testing a new Django application on aws beanstalk. While looking through the httpd error logs I see thousands of lines like this:
... Invalid HTTP_HOST header: 'api-keyboard.cmcm.com'. You may need to add 'api-keyboard.cmcm.com' to ALLOWED_HOSTS.*
Normally this is because I didn't add my own hostname to ALLOWED_HOSTS but this domain is completely foreign to me and I can't find references to it online.
So I'm wondering what this means, how do random host like this end up in the header, and if anyone recognized this one.
Thanks!
I have two Django applications working on the AWS Lightsail. First one is working great with www.firstapp.com and firstapp.com, but when I try to visit the second app without www in URL, it returns 400 Bad Request. In both apps, DEBUG set to False, and I have necessary hosts in settings.py like this:
ALLOWED_HOSTS = [
'.secondapp.com'
]
I have tried with '*' and also tried to write down all possible hosts in ALLOWED_HOSTS but it didn't work. I am able to see website with www.secondapp.com but secondapp.com always return Bad Request (400)
After any update in settings.py, I always restart Apache (tried to reload also) nothing changes, still getting 400 Bad Request. Any ideas? Maybe I should set up AWS in some way, this is my first experience with Django
For anyone who will face this kind of issues, check your VirtualHost configurations. In my VirtualHost configurations I had ServerName as www.secondapp.com when I add ServerAlias secondapp.com it works. Now I am able to see my app with www.secondapp.com and secondapp.com.
P.S.: However I don't have ServerAlias for first application but it still working as www.firstapp.com and firstapp.com, not sure why this casing an issue for the second one.
I have a Django website where I run multiple sites. Each application has a seperate apache instance and port assigned to it. the host.py file looks like the following
host_patterns = patterns('',
host(r'.*domain1.*', 'domain1.urls', name='domain1'),
host(r'.*domain2.*', 'domain2.urls', name='domain2'),
host(r'.*domain3.*', 'domain3.urls', name='domain3'),
host(r'.*domain4.*', 'domain4.urls', name='domain4'),
host(r'.*domain5.*', 'domain5.urls', name='domain5'),
)
for example www.domain1.com runs under an apache instance and port 8010.
Id like to create some internal monitors so I can check each site on a specific server. The only way to do this is with using port numbers of the apache instance so as http://10.10.10.10:8010 but when i try to modify my site to do this I get application errors.
either by adding a line for domain
host(r'.*8010.*', 'domain1.urls', name='domain1'),
or modifying existing line
host(r'.*domain1.*|.*8010.*', 'domain1.urls', name='domain1'),
not sure what I am doing wrong
I got this to work with the second option, i must have had a typo or something initially.
I'm by setting two domains that point to the same IP of Django, but I can just logging in to one, on the other just will not let me, from the admin or web always redirects me to the logging box, tried everything but nothing.
In test environment I have django running on runserer and the / etc / hosts as follows:
# This if it works
127.0.0.1 talleres.host1.com
# This one does not work
127.0.0.1 talleres.host2.com
I think the problem is with django but not to start looking, anyone know about this?
Make sure your ALLOWED_HOSTS looks like this:
ALLOWED_HOSTS = ['.host1.com',
'.host2.com',]