nginx 配置 (/etc/nginx/sites-enabled/default) 中:
upstream app {
    # Path to Unicorn SOCK file, as defined previously
    server unix:/tmp/unicorn.myapp.sock fail_timeout=0;
}
server {
    listen 80;
    server_name localhost;
    # Application root, as defined previously
    root /root/my_app/public;
    try_files $uri/index.html $uri @app;
    location @app {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app;
    }
    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;
我访问网站时 nginx 的 error log /var/log/nginx/error.log 中出现下面错误:
14/08/24 07:55:50 [error] 26968#0: *1 connect() to unix:/tmp/unicorn.myapp.sock failed (111: Connection refused) while connecting to upstream, client: 123.456.789.012, server: localhost, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.myapp.sock:/", host: "123.456.789.012"
查了下相关信息,这里有一样的情况:
http://stackoverflow.com/questions/5707938/unicorn-nginx-upstream-server-not-starting
但把 unix:/tmp/sockets/unicorn.sock 改成 127.0.0.1:3000,还是 Connect refused 错误。
具体原因在哪里呢?