AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1026240
Accepted
posop
posop
Asked: 2020-07-22 23:01:54 +0800 CST2020-07-22 23:01:54 +0800 CST 2020-07-22 23:01:54 +0800 CST

由 nginx uwsgi 服务的烧瓶应用程序返回 502

  • 772

我无法连接到由 nginx 和 uwsgi 提供的烧瓶应用程序(searx 搜索引擎)。

我的网络服务器显示“502 Bad Gateway nginx”

这是我的 nginx 错误:错误日志:/var/log/nginx/error.log

[crit] 2688#2688: *4 connect() to unix:/run/uwsgi/app/searx/socket.sock failed 
(2: No such file or directory) while connecting to upstream,
client: 216.186.XXX.XXX, server searx.mysite.com, 
request: "GET / HTTP/1.1", 
upstream: "uwsgi://unix:/run/uwsgi/app/searx/socket.sock:", 
host: "searx.mysite.com"

所以我可以看到socket.sock和上游不一样。

这是我的 nginx.conf

user http;
worker_processes auto;
worker_cpu_affinity auto;

events {
    multi_accept on;
    worker_connections 1024;
}

http {
    charset utf-8;
    sendfile on;
    tcp-nopush on;
    tcp_nodelay on;
    server_tokens off;
    log_not_found off;
    types_hash_max_size 4096;
    client_max_body_size 16M;

    include mime.types;
    default_type application/octet-stream;

    keepalive_timeout 65;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log warn;

    include /etc/nginx/sites-enabled/*;
}

这是我的 searx.conf,我指定 .sock 文件所在的唯一位置:

/etc/nginx/sites-enabled/searx.conf

server {
    listen 80;
    server_name searx.mysite.com;
    
    location / {
        include uwsgi_params;
        uwsgi_pass unix:/run/uwsgi/app/searx/socket.sock;
    }
    
    root /usr/local/searx/searx-src/searx;
    location /static { }
}

当我查看我的套接字文件夹时,那里没有文件......

ls -alh /run/uwsgi/app/searx/
total 0
drwxr-xr-x 2 searx searx 40 Jul 22 05:02 .
drwxr-xr-x 3 root  root  60 Jul 22 05:02 ..

我用来运行 uwsgi 的命令是:

exec chpst -u http env LC_ALL=en_US.UTF-8 /usr/bin/uwsgi --master --die-on-term --emperor /etc/uwsgi/sites

我用来运行 nginx 的命令:

exec chpst -u root /usr/bin/nginx -c /etc/nginx/nginx.conf -g "daemon off;"

这是我的 searx uwsgi 文件

/etc/uwsgi/sites/searx.ini

[uwsgi]
project = searx
uid = searx
gid = searx
base = /usr/local/searx/searx-src

chdir = %(base)/%(project)
env = SEARX_SETTINGS_PATH=/etc/searx/settings.yml

disable-logging = false
workers = 2

chmod-socket = 666
vacuum = true

single-interpreter = true
master = true
plugin = python
lazy-apps = true
enable-threads = true

module = searx.webapp

route-run = fixpathinfo:

virtualenv = /usr/local/searx/searx-pyenv
pythonpath = %(base)

# NOTE: if I add or delete the next line there is no difference in output
socket = /run/uwsgi/app/searx/socket.sock

更多挖掘:在我设置的 searx.ini中,在日志disable-logging = false中找到了这个:/var/log/uwsgi/current

thunder lock: disabled (you can enable it with --thunder-lock
bind(): Permission denied [core/socket.c line 230]
Wed July 22 15:05:31 2020 - [emperor] curse the uwsgi instance searx.ini (pid: 3320)
Wed July 22 15:05:31 2020 - [emperor] removed uwsgi instance searx.ini

所以我的 searx.ini 或者我怎么称呼它肯定有问题?

我不确定您可能需要哪些其他信息,但很高兴根据需要更新问题。我已经在这几天了,所以我非常感谢你能提供的任何帮助。

nginx uwsgi flask
  • 1 1 个回答
  • 1804 Views

1 个回答

  • Voted
  1. Best Answer
    posop
    2020-07-23T07:57:35+08:002020-07-23T07:57:35+08:00

    发现问题。回答谷歌后代...

    当然是文件权限:

    1. 我将用户 searx 添加到组 http: usermod -a -G http searx
    2. 我将 searx 目录更改为 http 作为它的组:chgrp -R http /usr/local/searx
    3. 我使 searx 目录可按组写入: chmod -R g+w user/local/searx
    4. 对我的 socket.sock 文件夹做了同样的事情: chgrp -R http /run/uwsgi/app/searx
    5. 并使该文件夹可按组写入:chmod -R g+w /run/uwsgi/app/searx
    6. 重启 nginx 和 uwsgi。
    • 1

相关问题

  • Gzip 与反向代理缓存

  • nginx 作为代理的行为

  • Nginx 学习资源 [关闭]

  • 提供 70,000 个静态文件 (jpg) 的最佳方式?

  • 在 Apache、LightTPD 和 Nginx Web 服务器上提供 PHP 5.x 应用程序的现状?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve