E
E
Eugene2019-02-09 14:13:04
Django
Eugene, 2019-02-09 14:13:04

How to solve the trouble with a bunch of nginx and wsgi?

Hello.
I needed to deploy a Django application. It was decided to use the django + wsgi + nginx bundle. Everything is done on ubuntu 18.
Made the following config

cat /etc/nginx/sites-available/lottery_service.conf 
#lot_serv.conf

upstream django {
  server 127.0.0.1:8001;
  }



server {

  listen 8000;

  server_name a.b.c.d;

  charset utf-8;

  client_max_body_size 75M;

  location /static {

    alias  /home/lottery_service/lottery_service/lottery_service_backend/static;
  }


  location / {
    uwsgi_pass django;
    include /home/lottery_service/lottery_service/lottery_service_backend/main/wsgi.py;
  }

There was a problem here:
sudo nginx -t
nginx: [emerg] unexpected """ in /home/lottery_service/lottery_service/lottery_service_backend/main/wsgi.py:1
nginx: configuration file /etc/nginx/nginx.conf test failed

The trouble is that I don't see any errors in the wsgi.py file:
cat wsgi.py 
"""
WSGI config for lottery_service project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings")

application = get_wsgi_application()

Help with a solution please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2019-02-09
@Eujene

The wsgi.py file does not store the nginx configuration, so trying to include it with a directive includeis a strange action.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question