参考記事
http://qiita.com/iwaseasahi/items/d5f2ef3eac5e349a8f7d
5まで行いました。
現在の問題。
ELB(ロードバランサ)経由でEC2にアクセスし、
DNSのec2-54-65-226-96.ap-northeast-1.compute.amazonaws.com
にアクセスすると、
sudo tail -f /var/log/nginx/access.log
にアクセス形跡が残る。
しかし、当然、求めているRailsの画面ではなく、nginxの初期画面。
一方、ElasticIP
にアクセスすると、サーバーが応答せず、accessログに何も出力されず。
ERR_CONNECTION_TIMED_OUT
sudo tail -f /var/log/nginx/error.log
にも何も出力されない。何か思いあたる原因はありますか。
ELBの設定が間違っているのか、それともRailsとunicornとnginxの設定が違うのか。
デプロイも挑戦して1ヶ月、アプリに問題はあるのだろうか。$rails server
ではうごくのですが。
nginxの設定(/etc/nginx/conf.d/{アプリ}.conf)
upstream unicorn_server { server unix:/var/www/projects/offisee/tmp/sockets/.unicorn.sock fail_timeout=0; } server { listen 80; client_max_body_size 4G; server_name 54.65.226.96; keepalive_timeout 5; # Location of our static files root /var/www/projects/offisee/public; location ~ ^/assets/ { root /var/www/projects/offisee/public; } location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://unicorn_server; break; } } error_page 500 502 503 504 /500.html; location = /500.html { root /var/www/projects/offisee/public; } }
unicornの設定(/var/www/projects/{アプリ}/config/unicorn.conf.rb)
# set lets $worker = 2 $timeout = 30 $app_dir = "/var/www/projects/offisee" $listen = File.expand_path 'tmp/sockets/.unicorn.sock', $app_dir $pid = File.expand_path 'tmp/pids/unicorn.pid', $app_dir $std_log = File.expand_path 'log/unicorn.log', $app_dir # set config worker_processes $worker working_directory $app_dir stderr_path $std_log stdout_path $std_log timeout $timeout listen $listen pid $pid # loading booster preload_app true # before starting processes before_fork do |server, worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! old_pid = "#{server.config[:pid]}.oldbin" if old_pid != server.pid begin Process.kill "QUIT", File.read(old_pid).to_i rescue Errno::ENOENT, Errno::ESRCH end end end # after finishing processes after_fork do |server, worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end
結局
なんかRailsのトップページまでのパスにつながっていないイメージ。
routeファイルに名前空間とか使っているのがだめなのかな。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。