0

I try, in vain, to set up a demonstration website running under django. On azure we have 2 virtual machines accessible from a public address. The website must be launched on a azure virtual machine. Both virtual machines deploy a nginx server, but when I launch a nginx server on the 2nd virtual machine on another port, it's time out. It seems to me that this is a configuration problem.

The configuration I use is based on nginx, gunicorn , supervisor , django.

This is the django /site_show/miss_site/miss_site/setting.py file :

ALLOWED_HOSTS = ["*"]
STATIC_ROOT = '/site_show/miss_site/static/'
MEDIA_ROOT= os.path.join(BASE_DIR, 'media/')
MEDIA_URL= "/site_show/miss_site/media/"
TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'templates'),)
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',)
SITE_ID = 1

some django file :

/site_show/miss_site/manage.py
/site_show/miss_site/media and /site_show/miss_site/static/
also /site_show/miss_site/templates/ where the index.html is

config file for nginx

upstream sample_project_server {
  server unix:/site_show/miss_site/gunicorn.sock fail_timeout=0;
}
server {
    listen   8008;
    server_name *public_address*;
    client_max_body_size 4G;
    access_log /site_show/miss_site/logs/nginx-access.log;
    error_log /site_show/miss_site/logs/nginx-error.log warn;
    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect http;
        if (!-f $request_filename) {
            proxy_pass http://sample_project_server;
            break;
        }
    }
    location /static/ {
        autoindex on;
        alias   /site_show/miss_site/static/;
    }
    location /media/ {
        autoindex on;
        alias   /site_show/miss_site/media/;
    }

launch script :

NAME="showcase"                                                                                         
DJANGODIR=/site_show/miss_site                                                                                               
SOCKFILE=/site_show/miss_site/gunicorn.sock                                                                            
USER=www-data                                                                                 
GROUP=www-data                                                                               
NUM_WORKERS=3                                                              
DJANGO_SETTINGS_MODULE=miss_site.settings                                                                                
DJANGO_WSGI_MODULE=miss_site.wsgi                                                                                                                   
echo "Starting $NAME as `whoami`"

# Activate the virtual environment                                                                                                                                    

cd $DJANGODIR
source /site_show/site_env/bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH

RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR
themselves (do not use --daemon)                                                                     
exec gunicorn ${DJANGO_WSGI_MODULE}:application \
     --name $NAME \
     --workers $NUM_WORKERS \
     --user=$USER --group=$GROUP \
     --bind=unix:$SOCKFILE \
     --log-level=debug \
       --log-file=-

and supervisor.conf file :

[program:site_show]
command = /site_show/miss_site/./lauch_script.sh
user = www-data
stdout_logfile = /var/log/site_show/gunicorn_supervisor.log
redirect_stderr = true
environment=LANG=fr_FR.UTF-8,LC_ALL=fr_FR.UTF-8

After lot of hour of try, nginx don't serve the right files or don't serve anything. Thanks for your future answers.

1 Answer 1

0

Open port 8008 on Azure and the job is done.

2
  • 1
    I know you're excited, but please try to keep your language under control. Think of Stack Overflow as more like Wikipedia than like Reddit.
    – Suraj Rao
    Commented Aug 27, 2019 at 14:34
  • I understand, sorry.
    – Add411
    Commented Sep 16, 2019 at 20:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.