Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
404使用nginx、unicorn和rails设置子域时出错_Nginx_Ruby On Rails 3.2_Vps_Unicorn - Fatal编程技术网

404使用nginx、unicorn和rails设置子域时出错

404使用nginx、unicorn和rails设置子域时出错,nginx,ruby-on-rails-3.2,vps,unicorn,Nginx,Ruby On Rails 3.2,Vps,Unicorn,我有一个VPS,最近将我的服务器设置从apache/passenger移动到了nginx/unicorn,并添加了一个临时服务器。如果我直接点击服务器,我的应用程序不会出现问题。然而,如果我用暂存子域点击它,我会得到一个404。我怀疑独角兽有问题,但我无法解决 以下是我所拥有的: /etc/nginx/站点启用/代码标记 upstream unicorn { server unix:/tmp/unicorn.blog.sock fail_timeout=0; } server { li

我有一个VPS,最近将我的服务器设置从apache/passenger移动到了nginx/unicorn,并添加了一个临时服务器。如果我直接点击服务器,我的应用程序不会出现问题。然而,如果我用暂存子域点击它,我会得到一个404。我怀疑独角兽有问题,但我无法解决

以下是我所拥有的:

/etc/nginx/站点启用/代码标记

upstream unicorn {
  server unix:/tmp/unicorn.blog.sock fail_timeout=0;
}

server {
  listen 80 default deferred;
  server_name staging.codemarks.com;
  root /home/deployer/apps/codemarks/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 4G;
  keepalive_timeout 10;
}                                                                                                                                                                                                         
然后在/etc/hosts中

127.0.0.1       localhost.localdomain   localhost
xxx.xxx.xxx.xxx staging.codemarks.com   staging
我有一个站点的DNS记录,并添加了一个A记录以指向我的新IP。另外,我检查了/var/log/nginx/access.log,直接(成功)请求被记录下来,但使用staging.codemarks.com yeilds命中它

216.21.198.16 - - [26/Dec/2012:14:41:07 -0500] "GET /codemarks HTTP/1.1" 404 446 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/537.20 (KHTML, like Gecko) Chrome/25.0.1337.0 Safari/537.20
我刚开始使用独角兽,所以我不确定我错过了什么。由于直接命中是成功的,我怀疑是DNS问题还是缺少特定于域的unicorn设置,但我遇到了麻烦。提前感谢您的帮助

更新

/tmp/unicorn.blog.sock似乎不太合适,因为我偷了一部分装有它的铁路机车。不过,它应该可以工作,因为我将它作为我的unicorn配置传入:

config/unicorn.rb

root = "/home/deployer/apps/codemarks/current"
working_directory root
pid "#{root}/tmp/pids/unicorn.pid"
stderr_path "#{root}/log/unicorn.log"
stdout_path "#{root}/log/unicorn.log"

listen "/tmp/unicorn.blog.sock"
worker_processes 2
timeout 30
我通过(盲目和不知不觉地)运行以下命令来设置我的unicorn.blog.sock:

sudo update-rc.d -f unicorn_blog defaults