NGINX + unicorn + Rails 設定時のハマりどころ


Rails Tutorial の成果物を EC2 で動かすための環境構築でハマった箇所のメモです。

  1. unicorn と nginx の起動ユーザが一致している必要があるらしい。
    aws nginx + unicorn (13:permission dnined) while connecting to upstream でハマッた時に試したことのTIPS

  2. unicorn.sock ファイルの配置場所は、 /tmp/ではなく、railsディレクトリ配下の tmp/に配置する必要があるらしい。

  3. httpでアクセスすると、https にリダイレクトしてしまう場合、以下の設定を追加する。

    config/environments/production.rb
    # 既定値は、 config.force_ssl = true
    config.fore_ssl = false
    
  4. cssが反映されない場合、以下の設定を追加する。

    config/environments/production.rb
    config.serve_static_files = true