I recently created a droplet.When i accessed the django project by droplet ip address it works fine but when i access it using domain (SaporaSocial), default nginx page shows. My allowed host are:-
ALLOWED_HOSTS=['server-ip-address','www.saporasocial.me','.saporasocial.me','saporasocial.me']
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
When your Django project works fine with the server’s IP address but not with the domain name, and you’re seeing the default Nginx page when accessing via the domain, it usually indicates an issue with your Nginx configuration. The Nginx server block (virtual host) for your domain might not be correctly set up or may not be pointing to your Django application. Here are steps to troubleshoot and resolve this issue:
Ensure you have an Nginx server block for your domain that points to your Django application. The configuration should look something like this (adjust paths and details as per your setup):
server {
listen 80;
server_name saporasocial.me www.saporasocial.me;
location / {
proxy_pass http://127.0.0.1:8000; # Point to the Django server
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# other configuration...
}
This configuration assumes your Django app is running on localhost (127.0.0.1) and port 8000. Adjust the proxy_pass directive to point to where your Django app is running.
Ensure that the correct server block file is linked in the /etc/nginx/sites-enabled directory. You can do this by creating a symbolic link from the sites-available directory:
sudo ln -s /etc/nginx/sites-available/my_django_project /etc/nginx/sites-enabled/
Replace my_django_project with the name of your configuration file.
Run the following command to test your Nginx configuration for syntax errors:
sudo nginx -t
If everything is correct, restart Nginx to apply changes:
sudo systemctl restart nginx
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.