Я развертываю приложение rails на цифровом океаническом VPS. Я следил https://coderwall.com/p/yz8cha . Все сделано хорошо, но теперь браузер показывает только пустую страницу.
Журнал Nginx содержит:
2014/08/04 03:07:20 [crit] 20550#0: *4 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connectin$
2014/08/04 03:08:39 [crit] 20550#0: *11 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connecti$
2014/08/04 03:08:40 [crit] 20550#0: *11 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connecti$
2014/08/04 03:08:41 [crit] 20550#0: *11 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connecti$
2014/08/04 03:08:41 [crit] 20550#0: *11 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connecti$
2014/08/04 03:08:42 [crit] 20550#0: *11 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connecti$
2014/08/04 03:08:42 [crit] 20550#0: *14 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connecti$
2014/08/04 03:08:42 [crit] 20550#0: *19 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connecti$
2014/08/04 04:15:01 [error] 22883#0: *19 connect() failed (111: Connection refused) while connecting to upstream, client: 202.88.237.208, serv$
2014/08/04 04:40:46 [error] 29378#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 202.88.237.208, serve$
2014/08/04 04:45:22 [error] 29378#0: *10 connect() failed (111: Connection refused) while connecting to upstream, client: 202.88.237.208, serv$
2014/08/04 04:49:48 [crit] 31073#0: *1 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connectin$
2014/08/04 04:58:19 [crit] 31073#0: *4 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connectin$
2014/08/04 04:58:38 [crit] 31073#0: *7 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connectin$
2014/08/04 04:59:45 [crit] 32683#0: *1 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connectin$
2014/08/04 05:00:28 [crit] 32683#0: *4 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connectin$
2014/08/04 05:00:29 [crit] 32683#0: *4 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connectin$
2014/08/04 05:08:15 [crit] 32683#0: *8 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connectin$
2014/08/04 05:09:50 [crit] 32683#0: *11 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connecti$
2014/08/04 05:30:02 [crit] 32683#0: *14 connect() to unix:/var/run/unicorn.testvpsdo.sock failed (2: No such file or directory) while connecti$
Я сменил каталог, и теперь отображается ошибка:
2014/08/04 05:34:18 [emerg] 1985#0: invalid host in upstream "/tmp/unicorn.testvpsdo.sock" in /etc/nginx/sites-enabled/testvpsdo:2
2014/08/04 05:36:35 [emerg] 2459#0: invalid host in upstream "/tmp/unicorn.testvpsdo.sock" in /etc/nginx/sites-enabled/testvpsdo:2
Конфигурация Nginx:
upstream unicorn {
server unix:/tmp/unicorn.testvpsdo.sock fail_timeout=0;
}
server {
listen 80 default_server deferred;
# server_name example.com;
root /home/navin/apps/testvpsdo/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 20M;
keepalive_timeout 10;
}
Я не знаю, как это исправить, хотя искал на многих сайтах.
Nginx не может получить доступ к вашему файлу сокета из-за разрешений. Попробуй это:
sudo mkdir /var/sockets
sudo chmod -R 755 /var/sockets
sudo mv /tmp/unicorn.testvpsdo.sock /var/sockets/unicorn.testvpsdo.sock
Затем укажите новый каталог сокета в nginx.conf и в файле unicorn.rb. Повторно разверните и посмотрите, что произойдет.