Nginx + Puma配置

3
这是我的puma配置:

path = Dir.pwd + "/tmp/puma/"

threads 0,20
environment "production"
daemonize true
drain_on_shutdown true

# _load_from path

bind  "unix://" + path + "socket/puma.sock"
pidfile path + "pid/puma.pid"
state_path path + "pid/puma.state"

这是我的nginx配置:

upstream rails_app {
  server /srv/rails/project/tmp/puma/socket/puma.sock;
}

server {
# server_name domain.tld www.domain.tld;
  root /srv/rails/project/public;

  try_files $uri/index.html $uri @rails_app;

  location @rails_app {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;

    proxy_pass http://rails_app;
  }

  error_page 500 504 /500.html;
  error_page 502 /502.html;
  error_page 503 /503.html;

  client_max_body_size 4G;
  keepalive_timeout 10;
}

然而,当我重新启动nginx时:

sudo service nginx restart

I get this:

Starting nginx: nginx: [emerg] invalid host in upstream "/srv/rails/project/tmp/puma/socket/puma.sock" in /etc/nginx/sites-enabled/default:2
nginx: configuration file /etc/nginx/nginx.conf test failed

我可以在这里获得更多线索:
tail -f /var/log/nginx/error.log
2014/04/30 09:07:33 [error] 7517#0: *1 directory index of "/srv/rails/project/" is forbidden, client: <ip address>, server: , request: "GET / HTTP/1.1", host:  <ip address>
2014/04/30 09:35:55 [emerg] 8245#0: invalid host in upstream "/srv/rails/project/tmp/puma/socket/puma.sock" in /etc/nginx/sites-enabled/default:2

但是对我来说,这意义不大,恐怕无法理解!

另外,我正在将我的pid和sock存储在项目根文件夹中。在Ubuntu服务器上,它们应该放在专门的位置吗?

1个回答

6

您的配置不正确。正确的上游路径应为:

server unix:///srv/rails/project/tmp/puma/socket/puma.sock;

unix://表示它是一个套接字。例如,您还可以使用tcp://并将其指向端口,如tcp://127.0.0.1:8080


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接