RailsでSSL通信をしたいのですが、どうすれば実現できますか?
どなたか教えてください。
宜しくお願いします。
気になる質問をクリップする
クリップした質問は、後からいつでもMYページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
回答2件
0
ベストアンサー
2 つの方法を紹介します。(forse_ssl() での方法は既に回答がありましたが)
...
特定のコントローラをHTTPSリクエストに強制する...
force_ssl([オプション])
オプション 説明
host Redirect to a different host name
subdomain Redirect to a different subdomain
domain Redirect to a different domain
port Redirect to a non-standard port
path Redirect to a different path
status Redirect with a custom status (default is 301 Moved Permanently)
flash Set a flash message when redirecting
alert Set an alert message when redirecting
notice Set a notice message when redirecting
only The callback should be run only for this action
except The callback should be run for all actions except this action
if symbol naming an instance method or a proc; the callback
unless A symbol naming an instance method or a proc; the callback
...
...
config/environments/production.rb
SampleApp::Application.configure do
略Force all access to the app over SSL, use Strict-Transport-Security,
and use secure cookies.
config.force_ssl = true
略
end
#でコメント化されている行があるので外します。
config/environments/production.rb で force_ssl = true にすれば、全てのリクエストが 強制的に HTTPSプロトコルになります。
See also: http://ruby.studio-kingdom.com/rails/guides/configuring のページ中で ssl を検索。
投稿2014/09/21 04:25
総合スコア22324
あなたの回答
tips
太字
斜体
打ち消し線
見出し
引用テキストの挿入
コードの挿入
リンクの挿入
リストの挿入
番号リストの挿入
表の挿入
水平線の挿入
プレビュー
質問の解決につながる回答をしましょう。 サンプルコードなど、より具体的な説明があると質問者の理解の助けになります。 また、読む側のことを考えた、分かりやすい文章を心がけましょう。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2014/09/24 04:34