Allowed host configuration for Django on EC2

I just popped up on the Amazon EC2 bitnami djnago stack and I am having problems with the ALLOWED_HOSTS value in the settings.py file. I'm not sure which hostname to use or where to find it. I tried internal IP, external IP, localhost, domain name. The only thing that stops 500 error pages is:

ALLOWED_HOSTS = ['*'] 

But this is a security issue. What am I missing?

+6
source share
1 answer

Ask him -

 ALLOWED_HOSTS = [ '.yourdomain.com' ] 

Where yourdomain.com is the domain name that you use to access it.

the documentation says -

The values ​​in this list can be fully qualified names (for example, "www.example.com"), in which case they will be mapped to the prompts for the Host header exactly (case insensitive, not including the port). A value starting with a period can be used as a wildcard subdomain: ".example.com" will match example.com, www.example.com and any other subdomain of example.com.

When you install it on www.yourdomain.com , there should be some request for a subobject other than www . This caused a problem. I can’t say for sure, because I do not have such information.

+12
source

Source: https://habr.com/ru/post/944648/


All Articles