大网数据广告活动
服务器运维问答

How to use UNIX domain sockets behind Apache / mod_proxy_uwsgi?

· 52CE 我爱测

On my development system I'm running a Flask WSGI application with uwsgi and nginx. However on the production server I need to use Apache instead of nginx, so I'm trying to do that. In nginx the site is mounted like this: locatio…

问题原文

原帖链接 · musbur · CC BY-SA 4.0

On my development system I'm running a Flask WSGI application with uwsgi and nginx. However on the production server I need to use Apache instead of nginx, so I'm trying to do that. In nginx the site is mounted like this:

location /flaskapp { uwsgi_pass unix:/tmp/flaskapp.sock; }

and it works. In Apache I tried this:

 ProxyPass /flaskapp unix:/tmp/flaskapp.sock|uwsgi://flaskapp

which gives me a 503 error with this in the logfile:

[Fri Jan 01 13:19:45.551524 2021] [proxy:error] [pid 14167] (2)No such file or directory: AH02454: uwsgi: attempt to connect to Unix domain socket /tmp/flaskapp.sock (flaskapp) failed
[Fri Jan 01 13:19:45.551802 2021] [:error] [pid 14167] [client ::1:48950] AH10101: failed to make connection to backend: httpd-UDS:0

I enabled both mod_proxy and mod_proxy_uwsgi modules. I don't understand the "no such file or directory" bit. The socket file is clearly where it's supposed to be.

Of course I stopped nginx and then re-started Apache to prevent nginx from keeping a hold on that socket.

The documentation of the ProxyPass directive doesn't explain what the part after the pipe ("|") character means so I don't know what to put there and why.

已采纳解答

原帖链接 · PaulR · CC BY-SA 4.0

I had a similar setup for a Django application and resolved this error message by moving the location of the socket file from /tmp to /var/lib/uwsgi. Make sure that /var/lib/uwsgi is owned by the same user and group that your web server and uWSGI run under so that uWSGI can create the socket file.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-01-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。