Answer the question
In order to leave comments, you need to log in
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;
}
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
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()
Answer the question
In order to leave comments, you need to log in
The wsgi.py file does not store the nginx configuration, so trying to include it with a directive include
is a strange action.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question