{"id":3218,"date":"2021-06-05T07:22:11","date_gmt":"2021-06-04T22:22:11","guid":{"rendered":"https:\/\/ecpplus.net\/weblog\/?p=3218"},"modified":"2021-06-10T16:52:36","modified_gmt":"2021-06-10T07:52:36","slug":"rails6-host-authorization","status":"publish","type":"post","link":"https:\/\/ecpplus.net\/weblog\/rails6-host-authorization\/","title":{"rendered":"Rails6 \u3067 LoadBalancer \u304b\u3089\u306e\u30d8\u30eb\u30b9\u30c1\u30a7\u30c3\u30af\u304c 403 \u306b\u306a\u3089\u306a\u3044\u3088\u3046\u306b\u3059\u308b"},"content":{"rendered":"<h2>\u554f\u984c<\/h2>\n<p>Rails6 \u304b\u3089\u5c0e\u5165\u3055\u308c\u305f <code>DNS rebinding protection<\/code> \u306b\u3088\u3063\u3066\u3001 <code>config.hosts<\/code> \u306b\u5b9a\u7fa9\u3057\u305f host \u4ee5\u5916\u306e host \u3092\u4f7f\u3063\u3066\u30a2\u30af\u30bb\u30b9\u3055\u308c\u305f\u5834\u5408\u3001403 \u304c\u8fd4\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3002<\/p>\n<p>\u901a\u5e38\u306e\u30a2\u30af\u30bb\u30b9\u6642\u306f\u554f\u984c\u306a\u3044\u304c\u3001ALB \u7b49\u304b\u3089\u30d8\u30eb\u30b9\u30c1\u30a7\u30c3\u30af\u3055\u308c\u308b\u5834\u5408\u3001\u5b9a\u7fa9\u3057\u305f hosts \u3067\u306f\u306a\u304f EC2 \u306b\u5272\u308a\u5f53\u3066\u3089\u308c\u305f\u30a4\u30f3\u30bf\u30fc\u30ca\u30eb\u306a host (eg: <code>ip-100-100-100-100.ap-northeast-1.compute.internal<\/code>) \u304c\u4f7f\u308f\u308c\u308b\u305f\u3081\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u3002<\/p>\n<h2>\u89e3\u6c7a\u65b9\u6cd5<\/h2>\n<p><a target=\"_blank\" href=\"https:\/\/github.com\/rails\/rails\/pull\/38829\" rel=\"noreferrer noopener\">Add request exclusion to Host Authorization #38829 (rails\/rails)<\/a> \u3067\u8ffd\u52a0\u3055\u308c\u305f <code>config.host_authorization<\/code> \u3092\u4f7f\u3044\u30aa\u30d7\u30c8\u30a2\u30a6\u30c8\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3002<\/p>\n<pre><code class=\"language-ruby\">config.host_authorization = { \n  exclude: -&gt; (request) { request.path == &#039;\/health_check&#039; }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u554f\u984c Rails6 \u304b\u3089\u5c0e\u5165\u3055\u308c\u305f DNS rebinding protection \u306b\u3088\u3063\u3066\u3001 config.hosts \u306b\u5b9a\u7fa9\u3057\u305f host \u4ee5\u5916\u306e host \u3092\u4f7f\u3063\u3066\u30a2\u30af\u30bb\u30b9\u3055\u308c\u305f\u5834\u5408\u3001403 \u304c\u8fd4\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2521,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[33,10],"class_list":["post-3218","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development","tag-aws","tag-rails"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/3218","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/comments?post=3218"}],"version-history":[{"count":3,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/3218\/revisions"}],"predecessor-version":[{"id":4036,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/3218\/revisions\/4036"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/media\/2521"}],"wp:attachment":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/media?parent=3218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/categories?post=3218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/tags?post=3218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}