I have deployed a Django project in digitalocean ubuntu 16.04.My domain name is like example.com
Because I want to add www. in front of my domain name so that if input www.example.com it can also direct to my website.
I bought my domain name from hostgator.
I first added www.example.com in my digitalocean DNS records to let www.example.com direct to my ip address.
Then I added www.example.com to myproject.setting in django to
ALLOWED_HOSTS = ['.example.co','www.example.com']
Third I went to
sudo nano /etc/nginx/sites-available/myproject
to add www.example.com in nginx
server {
listen 80;
server_name example.com www.example.com;
}
Then I test and restart nginx and gunicorn without any issue.
But I still received the issue DisallowedHost at / Invalid HTTP_HOST header: 'www.example.com'. You may need to add 'www.example.com' to ALLOWED_HOSTS when use www.example.com
Only example.com works.
Any friend can help?
Thank you so much!