将uwsgi与Nginx连接不起作用

问题描述 投票:0回答:1

我正在尝试通过uwsgi与nginx连接django应用程序,但是似乎没有发生将数据传递给uwsgi的情况。我已经测试了uwsgi服务器是否正常运行,并且两端都没有任何日志输出。

uwsgi.ini

[uwsgi]
module = MyDjangoApp.wsgi:application
master = True

;http-socket = :8001 #to run uwsgi on its one to ensure that it works

socket = :8001

vacuum = True
max-requests = 5000
plugin = python3
enable-threads = True

/ etc / nginx / sites-available文件树

  • 默认
  • serverDjango_nginx.conf

serverDjango_nginx.conf:

# the upstream component nginx needs to connect to
upstream django {
    #server unix:///path/to/your/mysite/mysite.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      8000;
    # the domain name it will serve for
    server_name 127.0.0.1; # substitute your machine's IP address or FQDN
    charset     utf-8;

    # max upload size
    client_max_body_size 75M;   # adjust to taste

    # Django media
   # location /media  {
# location /media  {
   #     alias /path/to/your/mysite/media;  # your Django project's media files $
   # }

   # location /static {
   #     alias /path/to/your/mysite/static; # your Django project's static files$
   # }

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include     /home/pi/Server/uwsgi_params; # the uwsgi_params file you in$
    }

更新:

首先,该站点未启用...第二,正如文档所说,我已经在/ etc / nginx / sites-enabled /中添加了指向它的链接现在我得到这个奇怪的错误:

在[/ etc / nginx / nginx.conf:63

我查看了相应的配置文件以找到

include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*;

现在我想知道为什么id找不到我链接到的文件

sudo ln -s〜/ etc / nginx / sites-available / serverDjango_nginx.conf / etc / nginx / sites-enabled /
python django nginx uwsgi
1个回答
1
投票
site是用于生成Nginx配置文件的好工具。在server块中,应将listen放到80443中(如果希望通过标准的http / s端口访问它)。您还应该将您的server_name设为您的域,例如www.google.com google.com(是同时包含两者)或您要在其上投放Django网站的任何域。

我也不像您在外地那样使用uwsgi。我只是像proxy_pass一样使用proxy_pass http://localhost:8001,然后为我的代理配置传递include

© www.soinside.com 2019 - 2024. All rights reserved.