nginxで"111: Connection refused"が出る場合の対処方法
さくらクラウド(Ubuntu14.04)でnginx, rails unicornを利用した際に以下の様なログが出る場合がある
2015/01/01 12:12:12 [error] 8652#0: *228 connect() failed (111: Connection refused) while connecting to upstream, client: 111.111.111.111, server: 222.222.222.222, request: "GET /entries HTTP/1.1", upstream: "http://[::1]:3999/entries", host: "222.222.222.222", referrer: "http://222.222.222.222/entries/1"
この場合、nginxにて用いている"localhost"がipv6になっている為Connection refusedになっている。
/etc/hostsを編集
before
::1 localhost ip6-localhost ip6-loopback
after
::1 ip6-localhost ip6-loopback
Rails Composerを使って簡単Webアプリ構築
サイト
新しいアプリの作成
rails new foo -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
こんなことが出来る
- Deviseの導入
- Bootstrapの導入
- Postgresの指定、設定ファイル自動生成
- Google Analyticsの設定
- development, productionのWebサーバ設定
deviseを利用可能にしている場合は作成後、以下のユーザでログイン出来る
外部公開する際には変更する必要有
- user@example.com
- changeme
WebrickでRailsの起動ポートを変更する
例:4000番ポートを指定する場合
config/boot.rbに以下を追記する
require 'rails/commands/server' module Rails class Server def default_options super.merge({ :Port => 4000, }) end end end