###前提・実現したいこと
Railsでアプリケーションを作成しています。
VPSを利用しubuntu+nginx+unicornで公開する環境を構築しているのですが、タイムアウトになってしまいます。
ログもnginxのaccessログしか出力されません。
unicornのログは一切出力されていません。
ですので、どこがどうダメなのか全く手がかりもつかめない状況です。
せめてエラーログが出力されて、原因がnginxなのかunicornなのかを
解明したいです。
###発生している問題・エラーメッセージ
/var/log/nginx/access.log
"GET / HTTP/1.1" 301 5 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0" "-"
###該当のソースコード
/etc/nginx/nginx.conf
user nginx; worker_processes 2; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; server_tokens off; }
/etc/nginx/conf.d/{アプリ名}.conf
upstream unicorn { server unix:/var/www/{アプリ名}/shared/tmp/sockets/unicorn.sock; } server { listen 80 default_server; server_name {ドメイン}; root /var/www/{アプリ名}/current/public; try_files $uri @unicorn; location @unicorn { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_pass http://unicorn; proxy_redirect off; } }
unicornのconf
@deploy_path = "/var/www/{アプリ名}" @shared_path = "#{@deploy_path}/shared" worker_processes 2 timeout 30 stderr_path "#{@shared_path}/log/unicorn.stderr.log" stdout_path "#{@shared_path}/log/unicorn.stdout.log" listen "#{@shared_path}/tmp/sockets/unicorn.sock" pid "#{@shared_path}/tmp/pids/unicorn.pid" preload_app true before_fork do |server, worker| if defined?(ActiveRecord::Base) ActiveRecord::Base.connection.disconnect! end old_pid = "#{server.config[:pid]}.oldbin" if File.exists?(old_pid) && server.pid != old_pid begin Process.kill("QUIT", File.read(old_pid).to_i) rescue Errno::ENOENT, Errno::ESRCH end end end after_fork do |server, worker| if defined?(ActiveRecord::Base) ActiveRecord::Base.establish_connection end end
あなたの回答
tips
プレビュー