Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Setting up Django with uWSGI and nginx - I've been trying to figure this out for 5 days now. Please help...

I'm trying to set up nginx server with my django app and uWSGI, by following this tutorial: https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html
I've been able to follow it up until the socket testing. The test itself doesn't produce an error, but localhost:8000 always returns 502 bad gateway error. I have been troubleshooting this for hours but can't figure out what I'm doing wrong.

/etc/nginx/nginx.conf:
```
#user http;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;
# load configs
include /etc/nginx/sites-enabled/*;
types_hash_max_size 4096;
server_names_hash_bucket_size 128;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;

location / {
root /home/<userprofile>/Projects/<project-name>/mymoon/journey/templates/journey/; # /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
```
/etc/nginx/sites-available/mymoon.conf
```
# mymoon_nginx.conf

# the upstream component nginx needs to connect to
upstream django {
server unix:///home/Projects/<project-name>/mymoon/journey/journey.sock; # for a file socket
server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}

# configuration of the server
server {
# the port your site will be served on
listen

/r/djangolearning
https://redd.it/sc7jt2