我一直坚持使用生产服务器。已经尝试解决它2天但不明白为什么会这样发生。 问题是: 我试图用nginx / unicorn / capistrano部署Rails应用程序。最后,我让这个过程正常运行。 Nginx和unicorn在我的生产服务器上似乎没问题,但是当我进入我服务器的IP时,只有一个空白屏幕。在我到那里之前至少有一条消息说nginx被运行了。我想问题可能是nginx和独角兽正在一个错误的地方搜索应用程序,但我检查了路线,他们似乎是正确的。 该应用程序有一个root欢迎页面,所以应该在那里显示...
你能帮我解决一下可能存在的问题吗?
P.S。如果我在服务器上创建一个测试rails应用程序并使用webricks运行它,则显示在MY_SERVER_IP:3000,所以问题肯定是unicorn / nginx。
我的nginx.conf文件:
upstream unicorn {
server unix:/tmp/unicorn.foreignernetwork.sock fail_timeout=0;
}
server {
listen 80 default deferred;
server_name justforeign.com;
root /var/www/foreignernetwork/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;
}
我的unicorn.rb文件:
root = "/var/www/foreignernetwork/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.foreignernetwork.sock"
worker_processes 2
timeout 30
# Force the bundler gemfile environment variable to
# reference the capistrano "current" symlink
before_exec do |_|
ENV["BUNDLE_GEMFILE"] = File.join(root, 'Gemfile')
end