dimanche 28 juin 2015

How to confirm Gunicorn is using Nginx as proxy?

I am using django as my web framework, gunicorn as the server and Nginx as the proxy server. I have gunicorn running at localhost:8080 & nginx at localhost:80.

Now how do I confirm that gunicorn is indeed using nginx as the (proxy) server? Also is my site supposed to be hosted at 8080?

gunicorn_start.sh:

APPNAME=comments
APPDIR=/home/ubuntu/$APPNAME/

LOGFILE=$APPDIR'gunicorn.log'
ERRORFILE=$APPFIR'gunicorn-error.log'

NUM_WORKERS=3

ADDRESS=0.0.0.0:8000

cd $APPDIR

source ~/.bashrc
# workon $APPNAME

exec gunicorn $APPNAME.wsgi:application \
-w $NUM_WORKERS --bind=$ADDRESS \
--log-level=debug \
--log-file=$LOGFILE 2>>$LOGFILE  1>>$ERRORFILE &

/etc/nginx/sites-available/example:

upstream hello_app_server {
  server unix:/home/ubuntu/nis_comments/run/gunicorn.sock fail_timeout=0;
}

server {
    listen   80;
    server_name ec2-[myip].compute-1.amazonaws.compute-1;

    client_max_body_size 4G;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    location /static/ {
        alias   /home/ubuntu/comments/static;
    }

    location /media/ {
        alias   /home/ubuntu/comments/;
    }

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_set_header Host $http_host;

        proxy_redirect off;

        if (!-f $request_filename) {
            proxy_pass http://hello_app_server;
            break;
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire