Home > Software design >  Moving a Django app into production using Nginx and Gunicorn, there are no errors but the page doesn
Moving a Django app into production using Nginx and Gunicorn, there are no errors but the page doesn

Time:08-16

I'm trying to setup an app on my Digital Ocean production server, I've followed these instructions, testing gunicorn and nginx,I could access the app in gunicorn and both services start fine with no errors logged. However when I go to the site it does not show anything. This is a subdomain of my main site. Mostly I'm looking to find a place to start troubleshooting this especially since everything looks fine.

Configs:

Nginx config for subdomain (Django) site:

server {
  # use 'listen 80 deferred;' for Linux
  # use 'listen 80 accept_filter=httpready;' for FreeBSD
  listen 80;

  # set the correct host(s) for your site
  server_name subdomain.domain_name.com www.subdomain.domain_name.com;

  location = /favicon.ico {access_log off; log_not_found off;}
  location /static/ {
    root /path/to/static/files;
  }

  location / {
    include proxy_params;
    proxy_pass http://unix:/path/to/.sock/file;
  }

}

Nginx config for main (static) site:

server {
        listen 80 default_server;
        listen [::]:80 default_server;


        root /var/www/main_site_folder;

    index index.html index.htm index.nginx-debian.html;

        server_name domain_name www.domain_name;

        location / {
        try_files $uri $uri/ =404;
        }

}

[Unit]
Description=Description of the app
After=network.target

[Service]
User=MyUserName
Group=www-data
WorkingDirectory=/var/www/app_directory/
ExecStart=/path/to/venv/and/gunicorn --access-logfile - --workers 3 --bind unix:/var/www/app_dir/.sock_filename app_name.wsgi:application

[Install]
WantedBy=multi-user.target

CodePudding user response:

You could start by changing ALLOWED_HOSTS = ["*"] in settings.py. Also try accessing your URL through CURL.

CodePudding user response:

Solved by adding an A record for the sub-domain

  • Related