Skip to content

Latest commit

 

History

History
27 lines (23 loc) · 806 Bytes

eb_http_to_https.md

File metadata and controls

27 lines (23 loc) · 806 Bytes

Redirect http to https on Elastic Load Balancer

Source: AWS EB Samples - http2https

Pre-requisites: ELB with two listeners (80 and 443)

Add a .config file to .ebextensions folder with the following content:

Resources:
 AWSEBV2LoadBalancerListener:
  Type: AWS::ElasticLoadBalancingV2::Listener
  Properties:
    LoadBalancerArn:
      Ref: AWSEBV2LoadBalancer
    Port: 80
    Protocol: HTTP
    DefaultActions:
      - Type: redirect
        RedirectConfig:
          Host: "#{host}"
          Path: "/#{path}"
          Port: "443"
          Protocol: "HTTPS"
          Query: "#{query}"
          StatusCode: "HTTP_301"