Проект Django на AWS EC2, что нужно указать в ALLOWED_HOSTS?

Проблема

Я развернул свой проект на AWS EC2 с помощью docker. Когда ALLOWED_HOSTS установлен как '*', веб-сайт работает нормально, он выглядит так, как и должен быть. После переключения ALLOWED_HOSTS с '*' на AWS EC2 Public IPv4 DNS, веб-сайт отвечает Bad request 400. Это странно. Почему это произошло? Или я должен поставить другое значение вместо Public IPv4 DNS?

Вот конфигурация моего проекта

nginx.conf

user  root;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$host $remote_addr - $remote_user [$time_local] '
                      '"$request" $status $body_bytes_sent '
                      '"$http_referer" "$http_user_agent" '
                      '$request_time';


    access_log /var/log/nginx/access.log  main;
    access_log /dev/stdout;
    error_log /var/log/nginx/error.log;
    error_log /dev/stdout info;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    # Gzip Compression
    gzip on;
    # gzip_min_length 1000;
    gzip_types text/plain application/xml;
    gzip_proxied expired no-cache no-store private auth;
    gzip_vary on;

    include /etc/nginx/conf.d/*.conf;
}

custom_nginx.conf

# the upstream component nginx needs to connect to
upstream uwsgi {
    server unix:/code/demo.sock;
}

# configuration of the server
server {
    # the port your site will be served on
    listen 80;
    listen [::]:80;

    client_max_body_size 75M;   # adjust to taste

    # Django media
    location /media/  {
        alias /code/media/;   # your Django project's media files - amend as required
    }

    location /static/ {
        alias /code/static/; # your Django project's static files - amend as required
    }

    location / {
        uwsgi_pass  uwsgi;
        include     /etc/nginx/uwsgi_params;
    }

}

EC2 Детализация экземпляра

enter image description here

Вернуться на верх