Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Cloudfront with Rails
Search
haruharuharuby
July 27, 2016
Programming
140
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Cloudfront with Rails
Using cloudfront with rails.
2016.07.26 JAWS-UG Osaka Study Meeting
haruharuharuby
July 27, 2016
More Decks by haruharuharuby
See All by haruharuharuby
Effective AWS Step Functions
haruharuharuby
0
220
JP_Stripes 5th anniversary - Plan migration consideration -
haruharuharuby
0
110
Alexa Warming Up my Live Stream!
haruharuharuby
1
120
AAJUG meetup September
haruharuharuby
0
67
How Voice Technology is Changing Customer Experience from Brain Perspectives
haruharuharuby
0
110
IVSの盛り上げ役にAlexaをつかってみようか
haruharuharuby
0
1.2k
Let's make a blog with live streaming in 10 minutes
haruharuharuby
0
540
Alexa Audio Player @Deep Diving
haruharuharuby
0
310
VoiceLunchJp#02 Share VUI App and reputation
haruharuharuby
1
340
Other Decks in Programming
See All in Programming
Web Framework Benchmark Battle 2026, Any%
a_matsuda
2
2k
S3 TablesのIcebergデータに、AIエージェントからアクセスしてみた / 20261016developersio2026joetsu-accessing-iceberg-in-s3tables-via-agent
kasacchiful
PRO
0
150
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.5k
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
220
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
28
32k
最近”作らせてる” ローカルAIアプリの話
akit37
0
470
Workers Cache を知る
syumai
0
360
ChromeでローカルLLM
ryu1013
0
140
AmebaブログはKMPから卒業します
kmars0605
0
190
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
270
Simple Storage Service(S3) is not simple
iwatsukayura
0
290
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
160
Featured
See All Featured
Paper Plane (Part 1)
katiecoart
PRO
2
12k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.7k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
Accessibility Awareness
sabderemane
1
250
How GitHub (no longer) Works
holman
316
150k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
820
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
ラッコキーワード サービス紹介資料
rakko
1
5.3M
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Transcript
Cloudfront with Rails クラウドフロントとRails の ツンデレ な関係 2016.07.26 「AWSのおJAWSな使い方」JAWS-UG大阪&JAWS-UG関西女子会合同企画
自己紹介 TiNm’S( ティムズ )と読みます。 プログラマーです。 Ruby On RailsとAWSが主戦場です。 好きなAWS サービスは、OpsWorks。
花澤香菜ちゃん好き。 JAWS-UG-KOBE 所属。 ポケモンGOはまだやってません。
はじめに...
に をかぶせたら、 Webサービスが動かなくなった 体験談をお話します。 今回は... ※Railsはやったことあるけど、 AWSには構築したことないなあ。な人向けの内容です。
なぜ話したいと思ったか。
Cloudfrontはデプロイに20分くらいかかる。 「ちょっとかえて、デプロイ、20分待つ。」 を繰り返すと、時間だけが取られていく。 もう、Prime Video見るしかなくなる。
Agenda • RailsでCloudfrontを導入する理由 • 転送するhttpメソッドではまる。 • 転送するhttpヘッダではまる。 • Cookieの転送ではまる。 •
クエリストリングの転送ではまる。
RailsでCloudfrontを導入する理由
アセット※のキャッシング Cloudfrontにアセットを設置することで、 js、css、 imageファイルをキャッシュできる。 その昔、アセットは、 asset_sync などのgemを利 用してS3に配置していた。 この方法は現在推奨されていない。 (Heroku
も assets は、CDNに設置することを推 奨) 参考: http://guides.rubyonrails.org/asset_pipeline.html ※ Railsで言うところの静的なファイル群のことで、おもに js、css、画像ファイルがそれに当たる。
HTTPS化 Cloudfrontに証明書を設置して、 HTTPS化する。 サーバーやELBに証明書を入れ込む必要がないので、 Railsの設定を単純化できる。 また、バックエンドを httpにすることで、暗号化、複合化を Rails側で実施する必要がなくなり、パフォーマン ス的にも効果が見込める。 (証明書もACM(AWS
Certificate Manager)を利用すれば、証明書の管理もできて効率的。 )
WAFの導入 悪い人をCloudfrontで弾いてしまう。 SQLインジェクションなどの脆弱性対策も Cloudfrontでやってしまう。
1: 転送するhttpメソッドではまる。
POST, PUTできない (>m<)0 Cloudfrontが受信するHTTPメソッドの デフォルト設定はGET,HEADのみ。 (つまり静的サイト向け ) Rails(に限らずほとんどの Webアプリ)では、 PUT、POST、PATCH、DELETEの許可が必
須。 すべてのHTTPメソッドを許可する。
2: 転送するhttpヘッダではまる。
いつもoriginが返る。
Hostヘッダを転送しておく。 RailsはHostヘッダでResponse先を判断している。 Hostヘッダが転送されない場合、 Railsは、Responseとして”//”(ルート)返却する。 つまり、ELBやEC2インスタンスのアドレス (origin)が返ることになる。
3: cookieの転送ではまる。
ログインできん。 Cloudfrontをかぶせたとたんにログイ ンできない。
Cookieを転送する。 RailsのセッションはデフォルトでCookieを利用する。 Cookieが転送されないとログインもできない。
4: クエリストリングではまる。
検索できん。 検索機能でよくあるURL。 http://example.com/search?q=XXXXXXX originでは効くのに、Cloudfrontをかぶせると 効かなくなる。
クエリストリングを転送する。 Cloudfrontはデフォルトでquerystringを転送しない。 検索機能を提供するransack を利用するならこの設定が必須。
まとめると
• すべてのHTTPメソッドを許可する。 • Hostヘッダを転送する。 • (セッションデフォルトなら)Cookieを転送する。 • (gemによっては)クエリストリングを転送する。
明日は、 Alexa !!!!!!!!!!!!!! そして....
https://www.youtube.com/watch?v=vizNdRTXK90&feature=youtu.be