2016-05-15 162 views
1

我正在使用Puma運行我的rails應用程序,並試圖使我的nginx配置指向它。我發現了以下錯誤在我的Nginx的錯誤日誌:嘗試訪問Puma套接字時,nginx權限被拒絕

2016/05/15 15:18:41 [crit] 1611#0: *31 stat() "/home/rails/acceptable-trader/current/public//index.html" failed (13: Permission denied), client: 66.253.181.206, server: , request: "GET/HTTP/1.1", host: "trade.acceptableice.com" 
2016/05/15 15:18:41 [crit] 1611#0: *31 stat() "/home/rails/acceptable-trader/current/public/" failed (13: Permission denied), client: 66.253.181.206, server: , request: "GET/HTTP/1.1", host: "trade.acceptableice.com" 
2016/05/15 15:18:41 [crit] 1611#0: *31 connect() to unix:///home/rails/acceptable-trader/shared/tmp/sockets/acceptable-trader-puma.sock failed (13: Permission denied) while connecting to upstream, client: 66.253.181.206, server: , request: "GET/HTTP/1.1", upstream: "http://unix:///home/rails/acceptable-trader/shared/tmp/sockets/acceptable-trader-puma.sock:/", host: "trade.acceptableice.com" 
2016/05/15 15:18:41 [crit] 1611#0: *31 stat() "/home/rails/acceptable-trader/current/public/500.html/index.html" failed (13: Permission denied), client: 66.253.181.206, server: , request: "GET/HTTP/1.1", upstream: "http://unix:///home/rails/acceptable-trader/shared/tmp/sockets/acceptable-trader-puma.sock/", host: "trade.acceptableice.com" 
2016/05/15 15:18:41 [crit] 1611#0: *31 stat() "/home/rails/acceptable-trader/current/public/500.html" failed (13: Permission denied), client: 66.253.181.206, server: , request: "GET/HTTP/1.1", upstream: "http://unix:///home/rails/acceptable-trader/shared/tmp/sockets/acceptable-trader-puma.sock/", host: "trade.acceptableice.com" 
2016/05/15 15:18:41 [crit] 1611#0: *31 connect() to unix:///home/rails/acceptable-trader/shared/tmp/sockets/acceptable-trader-puma.sock failed (13: Permission denied) while connecting to upstream, client: 66.253.181.206, server: , request: "GET/HTTP/1.1", upstream: "http://unix:///home/rails/acceptable-trader/shared/tmp/sockets/acceptable-trader-puma.sock:/500.html", host: "trade.acceptableice.com" 
2016/05/15 15:18:41 [crit] 1611#0: *31 stat() "/home/rails/acceptable-trader/current/public//index.html" failed (13: Permission denied), client: 66.253.181.206, server: , request: "GET/HTTP/1.1", host: "trade.acceptableice.com" 
2016/05/15 15:18:41 [crit] 1611#0: *31 stat() "/home/rails/acceptable-trader/current/public/" failed (13: Permission denied), client: 66.253.181.206, server: , request: "GET/HTTP/1.1", host: "trade.acceptableice.com" 
2016/05/15 15:18:41 [crit] 1611#0: *31 connect() to unix:///home/rails/acceptable-trader/shared/tmp/sockets/acceptable-trader-puma.sock failed (13: Permission denied) while connecting to upstream, client: 66.253.181.206, server: , request: "GET/HTTP/1.1", upstream: "http://unix:///home/rails/acceptable-trader/shared/tmp/sockets/acceptable-trader-puma.sock:/", host: "trade.acceptableice.com" 
2016/05/15 15:18:41 [crit] 1611#0: *31 stat() "/home/rails/acceptable-trader/current/public/500.html/index.html" failed (13: Permission denied), client: 66.253.181.206, server: , request: "GET/HTTP/1.1", upstream: "http://unix:///home/rails/acceptable-trader/shared/tmp/sockets/acceptable-trader-puma.sock/", host: "trade.acceptableice.com" 
2016/05/15 15:18:41 [crit] 1611#0: *31 stat() "/home/rails/acceptable-trader/current/public/500.html" failed (13: Permission denied), client: 66.253.181.206, server: , request: "GET/HTTP/1.1", upstream: "http://unix:///home/rails/acceptable-trader/shared/tmp/sockets/acceptable-trader-puma.sock/", host: "trade.acceptableice.com" 
2016/05/15 15:18:41 [crit] 1611#0: *31 connect() to unix:///home/rails/acceptable-trader/shared/tmp/sockets/acceptable-trader-puma.sock failed (13: Permission denied) while connecting to upstream, client: 66.253.181.206, server: , request: "GET/HTTP/1.1", upstream: "http://unix:///home/rails/acceptable-trader/shared/tmp/sockets/acceptable-trader-puma.sock:/500.html", host: "trade.acceptableice.com" 

我試圖改變可接受的貿易商,puma.sock及其父文件夾由www數據所擁有,但沒有似乎做任何事情。

我nginx的站點文件是:

upstream puma { 
    server unix:///home/rails/acceptable-trader/shared/tmp/sockets/acceptable-trader-puma.sock; 
} 

server { 
    listen 80 default_server deferred; 
    # server_name example.com; 

    root /home/rails/acceptable-trader/current/public; 
    access_log /home/rails/acceptable-trader/current/log/nginx.access.log; 
    error_log /home/rails/acceptable-trader/current/log/nginx.error.log info; 

    location ^~ /assets/ { 
    gzip_static on; 
    expires max; 
    add_header Cache-Control public; 
    } 

    try_files $uri/index.html $uri @puma; 
    location @puma { 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header Host $http_host; 
    proxy_redirect off; 

    proxy_pass http://puma; 
    } 

    error_page 500 502 503 504 /500.html; 
    client_max_body_size 10M; 
    keepalive_timeout 10; 
} 

回答

3

這些錯誤被由於nginx的造成沒有權限訪問這些文件夾。如果通過

改變用戶喬敦 - R的nginx的:nginx的/文件夾/路徑

和仍然不工作,那麼它更可能是一個SELinux的錯誤。作爲一個快速的工作,你身邊可以嘗試

setenforce許可

這是不推薦,但它是一個測試,看看天氣是SELinux的相關或不相關。如果它在那之後起作用,您需要編輯您的SELinux策略以允許nginx具有訪問這些文件夾的正確權限。這裏的鏈接不是對於美洲獅,但仍然是一個很好的解讀如何解決這個錯誤: nginx error 13

+0

我得到「該程序'setenforce'目前尚未安裝,您可以通過鍵入apt-get install selinux -utils「當我嘗試setenforce寬容時,這讓我覺得我沒有安裝SELinux。此外,我給了套接字文件夾的權限:drwxrwxr-x 2 www-data www-data 4096 5月15日14:48 sockets –

+0

好的,我做了所有我的chown命令,分組爲:user,而不是user:group。這樣做正確解決了它。感謝您試圖幫助我! –

相關問題