unicorn.sock failed (13: Permission denied) while connecting to upstream

昨日まで使用できていたWebアプリが、[502 Bad Gateway]が表示され利用できなくなった。
nginxのエラーログを確認すると、Webアプリのunicorn.sockのパーミッションがなく、エラーになっている。
昨日まで使用できていたのと、nginxはrootで起動しているのでunicorn.sockのパーミッションがないというエラーが腑に落ちません。
またwebアプリとnginxのconfファイルなどは変更していません。

webアプリとnginxを停止、起動してみましたが状況は変わりませんでした。
使用できなくなった原因と解決方法、お気付きな点がございましたらご教授頂けないでしょうか?

環境

サーバ:Linuxサーバ(Red Hat Enterprise Linux 6.5)
Webアプリ:ruby on railsで構築(Rails 5.2.2)
Webサーバ:nginx1.14.2

nginx

error.log

12023/12/12 16:02:02 [crit] 57912#57912: *14 stat() "/usr/share/nginx/html/[app]/public/[app]//index" failed (13: Permission denied), client: **.***.**.**, server: localhost, request: "GET /[app]/ HTTP/1.1", host: "***.***.com" 22023/12/12 16:02:02 [crit] 57912#57912: *14 stat() "/usr/share/nginx/html/[app]/public/[app]/.html" failed (13: Permission denied), client: **.***.**.**, server: localhost, request: "GET /[app]/ HTTP/1.1", host: "***.***.com" 32023/12/12 16:02:02 [crit] 57912#57912: *14 stat() "/usr/share/nginx/html/[app]/public/[app]/" failed (13: Permission denied), client: **.***.**.**, server: localhost, request: "GET /[app]/ HTTP/1.1", host: "***.***.com" 42023/12/12 16:02:02 [crit] 57912#57912: *14 connect() to unix:/usr/share/nginx/html/[app]/tmp/sockets/unicorn.sock failed (13: Permission denied) while connecting to upstream, client: **.***.**.**, server: localhost, request: "GET /[app]/ HTTP/1.1", upstream: "http://unix:/usr/share/nginx/html/[app]/tmp/sockets/unicorn.sock:/[app]/", host: "***.***.com"

nginxはrootで起動

1$ ps aux | grep nginx 2root 57904 0.0 0.0 47328 1132 ? Ss 11:27 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf 3root 57905 0.0 0.0 60024 2268 ? S 11:27 0:00 nginx: worker process 4root 57906 0.0 0.0 60024 2268 ? S 11:27 0:00 nginx: worker process 5root 57907 0.0 0.0 60024 2544 ? S 11:27 0:00 nginx: worker process 6root 57908 0.0 0.0 60024 2268 ? S 11:27 0:00 nginx: worker process 7root 57910 0.0 0.0 60024 2300 ? S 11:27 0:00 nginx: worker process 8root 57911 0.0 0.0 60024 2544 ? S 11:27 0:00 nginx: worker process 9root 57912 0.0 0.0 60024 2268 ? S 11:27 0:00 nginx: worker process 10root 57913 0.0 0.0 60024 2544 ? S 11:27 0:00 nginx: worker process

nginx.conf

1user root;2worker_processes auto;3 4error_log /var/log/nginx/error.log warn;5pid /var/run/nginx.pid;6 7 8events {9 worker_connections 1024;10}11 12 13http {14 include /etc/nginx/mime.types;15 default_type application/octet-stream;16 17 log_format main '$remote_addr - $remote_user [$time_local] "$request" '18 '$status $body_bytes_sent "$http_referer" '19 '"$http_user_agent" "$http_x_forwarded_for"';20 21 access_log /var/log/nginx/access.log main;22 23 sendfile on;24 #tcp_nopush on;25 26 keepalive_timeout 65;27 28 #gzip on;29 30 include /etc/nginx/conf.d/*.conf;31}

application.conf

1upstream sample { 2 server unix:/usr/share/nginx/html/sample/tmp/sockets/unicorn.sock; 3} 4 5upstream [app] { 6 server unix:/usr/share/nginx/html/[app]/tmp/sockets/unicorn.sock; 7} 8 9server { 10 listen 80; 11 server_name localhost tnror3 tnror3.sandisk.com; 12 13 root /usr/share/nginx/html; 14 15 location /[app]{ 16 root /usr/share/nginx/html/[app]/public; 17 try_files $uri/index $uri.html $uri @[app]; 18 } 19 20 client_max_body_size 1G; 21 22 location @[app] { 23 proxy_set_header X-Real-IP $remote_addr; 24 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 25 proxy_set_header Host $http_host; 26 proxy_pass http://[app]; 27 #fastcgi_read_timeout 180; 28 send_timeout 180; 29 proxy_connect_timeout 1800; 30 proxy_read_timeout 1800; 31 proxy_send_timeout 1800; 32 } 33 34 location /sample { 35 root /usr/share/nginx/html/sample/public; 36 try_files $uri/index $uri.html $uri @sample; 37 } 38 39 location @sample { 40 proxy_set_header X-Real-IP $remote_addr; 41 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 42 proxy_set_header Host $http_host; 43 proxy_pass http://sample; 44 } 45}

シンボリックリンク/usr/share/nginx/html/

total 8 -rw-r--r-- 1 root root 537 Dec 5 2018 50x.html lrwxrwxrwx 1 root root 38 Mar 19 2019 [app] -> /home/[user]/rails/prod/[app] -rw-r--r-- 1 root root 612 Dec 5 2018 index.html lrwxrwxrwx 1 root root 34 Mar 19 2019 sample -> /home/[user]/rails/prod/sample

webアプリ

unicorn_error.log

1[2023-12-12 11:25:27.557732 #57497] INFO -- : reaped #<Process::Status: pid 57504 exit 0> worker=1 2[2023-12-12 11:25:27.557802 #57497] INFO -- : reaped #<Process::Status: pid 57506 exit 0> worker=2 3[2023-12-12 11:25:27.557870 #57497] INFO -- : master complete 4I, [2023-12-12T11:26:00.085373 #57816] INFO -- : Refreshing Gem list 5[2023-12-12 11:26:04.669826 #57816] INFO -- : unlinking existing socket=/home/[user]/rails/prod/[app]/tmp/sockets/unicorn.sock 6[2023-12-12 11:26:04.671201 #57816] INFO -- : listening on addr=/home/[user]/rails/prod/[app]/tmp/sockets/unicorn.sock fd=11 7[2023-12-12 11:26:04.685914 #57838] INFO -- : worker=0 ready 8[2023-12-12 11:26:04.687540 #57840] INFO -- : worker=1 ready 9[2023-12-12 11:26:04.688322 #57816] INFO -- : master process ready 10[2023-12-12 11:26:04.689128 #57842] INFO -- : worker=2 ready

unicorn.sock

1$ pwd 2/home/[user]/rails/prod/[app]/tmp/sockets 3$ ll 4total 0 5srwxrwxrwx 1 [user] rnroper 0 Dec 12 11:26 unicorn.sock

試したこと

webアプリ停止、起動 → 変化なし
nginx停止、起動 → 変化なし

コメントを投稿

0 コメント