当前位置: 首页 > 知识库问答 >
问题:

Django Nginx uWSGI 502总是坏网关

傅嘉悦
2023-03-14

我一直在关注http://uwsgi-docs.readthedocs.io/en/latest/tutorials/django_and_nginx.html

# configuration of the server
server {
    # the port your site will be served on
    listen      8000;
    # the domain name it will serve for
    server_name mytest.com; # substitute your machine's IP address or FQDN
    charset     utf-8;

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

    # Django media
    location /media  {
        alias /home/karesh/tutorial/uwsgi-tutorial/mysite/media;  # your Django project's media files - amend as required
    }

    location /static {
        alias /home/karesh/tutorial/uwsgi-tutorial/mysite/static; # your Django project's static files - amend as required
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  unix:/home/karesh/tutorial/uwsgi-tutorial/mysite/mysite.sock;
        include     /home/karesh/tutorial/uwsgi-tutorial/mysite/uwsgi_params; # the uwsgi_params file you installed
    }
}
uwsgi_param  QUERY_STRING       $query_string;
uwsgi_param  REQUEST_METHOD     $request_method;
uwsgi_param  CONTENT_TYPE       $content_type;
uwsgi_param  CONTENT_LENGTH     $content_length;

uwsgi_param  REQUEST_URI        $request_uri;
uwsgi_param  PATH_INFO          $document_uri;
uwsgi_param  DOCUMENT_ROOT      $document_root;
uwsgi_param  SERVER_PROTOCOL    $server_protocol;
uwsgi_param  REQUEST_SCHEME     $scheme;
uwsgi_param  HTTPS              $https if_not_empty;

uwsgi_param  REMOTE_ADDR        $remote_addr;
uwsgi_param  REMOTE_PORT        $remote_port;
uwsgi_param  SERVER_PORT        $server_port;
uwsgi_param  SERVER_NAME        $server_name;

共有1个答案

柴俊捷
2023-03-14

以下几点可能对您有所帮助:1)将运行uWSGI的用户添加到启用SE的CentOS上的nginxgroup2)。将套接字放置在/run :nginx 下的一个目录是3)将套接字权限设置为 :nginx (换句话说,为您的用户和nginx组设置套接字权限。

这些步骤通常帮助我找出权限错误。

 类似资料:
  • 我的nginx.conf文件是这样的: 现在,在打开一些URL时,它抛出了502个坏网关,但对其他URL则没有。我犯的错误。日志为: 2019/01/10 23:53:39[错误]12139#12139:*5 recv()在从上游读取响应头时失败(104:由对等方重置连接),客户端:127.0。0.1,服务器:localhost,请求:“GET/wordpress/HTTP/2.0”,上游:fas

  • Docx4J生成的Excel工作簿总是说损坏了,但我无法确定Excel不喜欢底层XML的什么,更不用说如何修复它了。 我的用例如下:我试图定期自动生成一个带有图表和图形的excel工作簿。只有原始数据会改变,但随着原始数据的改变,其他一切都会动态更新。 null null 在我的空白工作簿之前和之后 欢迎所有的想法。

  • 502网关错误。错误日志和nginx配置如下。有什么问题吗? [错误]7660#0:*10 connect()在连接到上游时失败(111:连接被拒绝),客户端:40.83。126.181,服务器:127.0。0.1,请求:“GET/HTTP/1.1”,上游:fastcgi://127.0.0.1:9000,主持人:“www.mysite.com” nginx。形态: vhost/home.conf

  • 我在裸机上安装了一个库伯内特斯集群(使用威睿虚拟机),节点如下 Metallb安装为集群的负载平衡器,calico安装为CNI 我还安装了带舵柄的nginx入口控制器 我部署了一个简单的nginx服务器进行测试 我使用负载均衡器类型的部署从metallb获得IP,工作正常,但当我添加入口时,尽管分配了IP,但我得到错误502坏网关,如下所示: 防火墙已启用,但所需端口已打开 我的服务和pods工作

  • 好的,我正在本地运行一个应用程序,homestead.app:8000。我正在运行流浪,这是在我“流浪停止”为Nginx更改文档根然后流浪后才开始发生的。 Nginx正在将502坏网关返回到浏览器,我的测试域的错误日志声明如下: 2014/05/18 21:37:11[crit] 1368#0:*7连接()到unix:/var/run/php5-fpm.sock失败(2:没有这样的文件或目录),同

  • 我用Ired邮件和两个网站成功地运行了Ubuntu服务器20.04,其中一个是WordPress。 我想安装Nextcloud,为此我必须重新安装php fpm以生成php7。4-fpm。短袜在这之后,Nextcloud工作了,但是我的其他网站停止了工作,出现了错误“502坏网关”。 所以至少可以说,我很困惑! 我根据本文安装了Nextcloud并设置了启用的站点。符合说明的conf文件:http