Gunicorn 502网关链接到sock文件的权限被拒绝错误

时间:2017-07-01 10:18:35

标签: django gunicorn

我正在设置django,gunicorn和nginx,当我访问主页时,我收到502网关错误。 日志显示它与sock文件的权限相关

2017/07/01 09:59:18 [crit] 12237#12237: *23 connect() to unix:/home/sammy/revamp/revamp/revamp.sock failed (13: Permission denied) while connecting to upstream, client: 105.49.30.134, server: $

权限是

srwxrwxrwx 1 sammy www-data       0 Jul  1 05:29 revamp.sock

gunicorn服务设置如此

[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/revamp
ExecStart=/home/sammy/revamp/revampenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/sammy/revamp/revamp.sock revamp.wsgi:application

[Install]
WantedBy=multi-user.target

权限看起来没问题,并且systemctl状态gunicorn处于活动状态。

更新 该文件夹的权限如下

total 2128
drwxr-xr-x 3 sammy root        4096 Jun 28 05:21 account
-rw-r--r-- 1 sammy root          48 Jun 27 09:34 brain
-rw-r--r-- 1 sammy root     1037922 Jun 28 11:34 data.json
-rwxr-xr-x 1 sammy root     1087488 Jun 27 09:35 db.sqlite3
drwxr-xr-x 4 sammy root        4096 Jun 28 05:21 gallery
-rw-r--r-- 1 sammy root        1326 Jun 27 09:34 hip-hop.txt
-rwxr-xr-x 1 sammy root           0 Jun 27 09:34 lUhbv4PA5t.jpg
-rwxr-xr-x 1 sammy root         249 Jun 27 09:34 manage.py
-rwxr-xr-x 1 sammy root         473 Jun 27 09:34 names.txt
-rw-r--r-- 1 sammy root         211 Jun 27 09:34 nsfw
-rw-r--r-- 1 sammy root         417 Jun 27 09:34 obsene.txt
-rwxr-xr-x 1 sammy root        1803 Jun 27 09:34 phrases.txt
drwxr-xr-x 5 sammy root        4096 Jul  1 07:59 revamp
drwxrwxr-x 6 sammy sammy       4096 Jul  1 05:14 revampenv
srwxrwxrwx 1 sammy www-data       0 Jul  1 05:29 revamp.sock
-rw-r--r-- 1 sammy root          97 Jun 27 09:33 to do

1 个答案:

答案 0 :(得分:0)

不仅文件本身,而且nginx进程也可以访问指向该文件的目录。

检查/home/sammy/home/sammy/revamp目录的权限。