LoginSignup
6
2

More than 3 years have passed since last update.

[playframework2.6]Host not allowed エラー/AllowedHostsFilter

Last updated at Posted at 2019-11-29

背景・問題点

やっとの思いでバージョンアップしてステージング環境にデプロイ。
実行して、ブラウザからアクセスしたら、BadRequest(400)エラー発生。はぁ・・・。

Host not allowed

原因

Play2.6では AllowedHostsFilter がデフォルトで有効で、アクセス許可されているのはlocalhost.localだけ。
このため実サーバにデプロイして外部からアクセスするとエラーになる。という仕組み。
移行ガイドにも珍しくしっかり書かれていたのですが、ローカルでは動いていたので、見落としました。汗

play.filters {
  hosts {
    allowed = ["localhost", ".local"]
  }

対処

上述したplay.filters.hosts.allowedにホスト名もしくはIPアドレスを設定します。

なおELBヘルスチェックを使う場合は、全許可['.']にする必要があります。

6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2