4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ElasticBeanstalkでhttpからhttpsにリダイレクトする(force https)

4
Last updated at Posted at 2017-10-17

結論

  • 以下を.ebextensions/* に配置してeb deploy
.ebextensions/initialize.config
files:
  #X-Forwarded-ProtoはELBから渡されるので、前段にELBがある場合のみ作用する
    "/etc/httpd/conf.d/ssl_rewrite.conf":
        mode: "000644"
        owner: root
        group: root
        content: |
            RewriteEngine On
            <If "-n '%{HTTP:X-Forwarded-Proto}' && %{HTTP:X-Forwarded-Proto} != 'https'">
            RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
            </If>

説明

  • /etc/httpd/conf.d/*.conf がapacheの追加設定として読み込まれます。
  • X-Forwarded-ProtoはELBから渡されるので、単一インスタンスに設定しているときにはELBがないので作用しません。
4
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
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?